Cannot insert data with the PDO function [from: insert and update of the server in the same shape behaviors]

I feel as if I'm fighting my way around a paper bag trying to insert a record.  I have recently converted from MySQL for PDP, which cannot be applied.  I'm not trying to write routines to update data and started with insert.  I tried the example in your PHP Solutions edition two, pp. 361-363, but I can't get a written account.

It is a database, which I supported since the host server using phpMyAdmin.  I'm very well display the data on the site, so I guess that my login script is ok.  However, nothing I've tried has got a registered insert.  I tried to get back to the basics, and it still does not work.  This is my current code.  Something is wrong with my statement = $sql and I can't identify the problem.  Help, please!

If (isset($_POST['insert'])) {}

try {}

create the SQL

$sql = "INSERT INTO Homepage_text (enriched, h_date, h_seq, h_col, p_heading, p_text, h_hide) VALUES ($_POST ['enriched'], $_POST ['h_date'], $_POST ['h_seq'], $_POST ['h_col'], $_POST ['p_heading'], $_POST ['p_text'], $_POST ['h_hide']);"

$sainttim-> execute ($sql);

echo "new record successfully created ';

}

catch (PDOException ($e) exception

{

echo $sql. "< br / > '. $e-> getMessage();

}

}

There are several things wrong with your code:

  • You use elements of an associative array within a double quoted string. Which will cause a parse error.
  • The values you are trying to insert in the database are for most (if not all) of the text fields. If you use a literal SQL query, text fields must be wrapped in quotes.
  • You try to use the method execute() with a literal SQL query. In AOP, execute() only works with a prepared statement. To run a literal SQL query, you must use the exec() method.
  • Passing the values in the array $_POST directly in the database without any sort of validation and without escaping quotes or other characters just asking for trouble.

Follow the examples in the book, and use a prepared statement. To address all these issues quickly and easily.

Tags: Dreamweaver

Similar Questions

  • Cannot filter data with the extended class

    Hello

    I have a small question on the PortableObject format. I created a class that extends PortableObject interface and implementation of methods of serializer as well. I've updated in the file config.xml - pof as well. If I insert the objects of that type of object in the cache, they get inserted correctly and I can filter the values based on the getters defined in the class. Everything works fine here.

    Now I'm expanding the existing class I. We have our custom API we have built for our domain objects. I need to store these objects in the cache. So, naturally, I need to implement the PortableObject interface for this. So, instead of creating a new class with the new series of getters and setters and local fields, I extend our domain class to create a new class that implements the PortableObject interface. Instead of setting the local fields and getters and setters, I'm reusing those provided by my existing class. Now, I can insert the new class objects in the cache. But I can't filter values for objects of this new class.

    Let me show you what exactly I am trying to achieve by giving a small example:

    Domain class:

    Class person
    *{*
    private String person_name;

    * public String getPerson_name() {return person_name ;} *}
    * public String setPerson_name (person_name) {this.person_name ;} person_name = *}
    *}*

    The new class that implements PortableObject interface:

    class ExtPerson extends implements person PortableObject
    *{*
    public static final PERSON_NAME = 0;

    * public Sub readExternal (PofReader reader) throws IOException {*}
    setPerson_name (reader.readString (PERSON_NAME));
    *}*

    * public methods void writeExternal (writer PofWriter) throws IOException {*}
    writer.writeString (PERSON_NAME, getPerson_name());
    *}*

    * / / And HashCode, Equals and ToString methods, all implemented using the Get accessor of the person class *.
    *}*

    So, if I create a new class ExtPerson extend the Person class and write all methods, store objects in the cache and run the following query, I get the size printed

    System.out.println ((cache.entrySet (EqualsFilter ("getPerson_name", "ABC"))) .size ());

    But if I use the extended class and insert the values into the cache and if I use the same query to filter, I get 0 displayed on the console.

    System.out.println ((cache.entrySet (EqualsFilter ("getPerson_name", "ABC"))) .size ());

    So, can anyone say exactly what is the cause?


    Thank you!

    ContainAnyFilter doesn't work the way you expect.

    Here's the java doc.

    "Filter that tests a value of Collection or array object returned by a method of containment of any value as a whole."

    The return of the object by the get method must be an array of Collection or an object, it will return false if the object of the return of Extractor is not a type of Collection or array.

    or in your case, it only works if the getPerson_name() returns an array of strings.

    You probably want to use talk.

  • Cannot create pdf with the same page size

    Hello

    I installed Adobe Acrobat Professional (writer). And created a pdf document. the pdf file contains images, each on his page. The problem is when I save or preview the document, some images are not sized for his area of page (or fit to page). Please check attached picture to see the problem.

    How can I add images to PDF with eqal size.

    Please check attached picture Pdfsnap1 & Pdfsnap2 (used the crop tool)...

    Someone helped me to visit the following link for the solution:

    http://forums.adobe.com/thread/841095

    Above the provided Adobe forum link is good, but 50% of my problem is solved. In other words, the selection of the image and using her crop tool 'page size' is increased, but the image on the page is still small, or it does not increase with the size of the page.

    Concerning

    Nauman

    pdfsnap.JPGpdfsnap2.JPG

    To resize the image, you need to select with the object tool and drag the buttons on the sides and the corners to resize it.

    Much of what you do can be done in Acrobat, but this isn't the ideal application for such actions. Acrobat isn't really an editing tool, but a tool to create a finished product that provides essentially platform independent product. You might find what you want to do is best done in a word processor or page layout tool, then a PDF file created from this result.

  • How to display XML data with the same form that generated?

    I am an inexperienced "developer", so bare with me please.  I just created an interactive form that my users will fill out and give me back.  I love the email button that let's them just click a button to send it - because it's so smooth.  However, all I get back is data XML that I don't know what to do with.  Is it possible that I can just open the form I send my users and have the XML data to automatically fill? Otherwise, suggestions?  I started a company - so it's just me without other resources (or fancy SQL DBs to pull this stuff, etc.).

    Hello

    You can configure a button on the form with the JavaScript next to the click event:

    xfa.host.importData ();

    This will open a window that will allow you to navigate to where you saved the returned XML file. Note that this button does not work in extended via Acrobat Forms.

    Depending on the version of Acrobat you are using (the menu changes slightly) you can go to the menu forms and select Manage form data / import data.

    Third option; You may also distribute the forms via Acrobat, which will put in place a response file, which will allow to import responses for you.

    Hope that helps,

    Niall

  • Can access VCSA with the root account, but cannot access vSphere with the same root account

    I am able to connect to the VCSA (: 5480) with the created password for root, but I can't log in vSphere (: 9443) with this same root account).  It seems that the password has been correctly set, but weird that I can connect to one and not the other.  I recently improved bed and breakfast ESXi and VCSA version 5.5 Update 2, but don't think that should have an effect on.  Any suggestions?  Help, please.

    Understand the problem.  When you change the field by default to another identity source, you must type root@localos as the user name to use the root account.

  • How to select data using the same remote database column name 3

    Hello


    Can anyone help me on how to get the data with the same remote database column names 3 and a unique nickname.

    E.g.

    SELECT *.
    B.SID, b.status, SUM (b.qty) qantity MAX (b.) date_as_of
    Of
    * ((table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3) has, *)
    (* (table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3) b). *
    WHERE b.dept = 'finance '.
    AND a.position = "admin".
    AND a.latest = 'Y' AND (b.status <>"MLT") AND b.qty > 0;
    B.SID GROUP, b.status;

    NOTE: the instructions "BOLD" is just an example of what I want to do but I always get an error beacause of ambiguous column.

    Thanks to advnce. :)

    Published by: user12994685 on 4 January 2011 21:42

    user12994685 wrote:

    Can anyone help me on how to get the data with the same remote database column names 3 and a unique nickname.

    Not valid. This makes no sense and breaks all the rules of scope-resolution. And if it is in a single database, or uses tables in databases, is not relevant.

    Each object must be particularly well identified. If you cannot do this:

    select * from (table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3) a
    

    3 objects cannot share the same alias. Example:

    SQL> select * from (dual, dual) d;
    select * from (dual, dual) d
                       *
    ERROR at line 1:
    ORA-00907: missing right parenthesis
    

    You need to combine objects - by using a join union or similar. He will have to be done as follows:

    SQL> select * from (select * from dual d1, dual d2) d;
    select * from (select * from dual d1, dual d2) d
           *
    ERROR at line 1:
    ORA-00918: column ambiguously defined
    

    However, we need to have unique column in a projection of SQL names - so the join of the need to project a unique set of columns. So:

    SQL> select * from (select d1.dummy as dummy1, d2.dummy as dummy2 from dual d1, dual d2) d;
    
    DUM DUM
    --- ---
    X   X
    
    SQL> 
    

    I suggest that you look carefully at what opportunities are and how it applies in SQL - and ignore if the referenced objects are local or remote, because it has no effect on the basic principles of scope-resolution.

  • What is always "stay up to date with the latest innovations in the field of photography from Adobe"?

    Hello

    I am considering buying stand-alone version 6 of Lightroom, but I wonder what does that "Always stay up to date with the latest innovations in photography from Adobe" is not available?

    Will be the updated standalone for free with the new camera support?

    Will be free updated standalone version with correction of defects?

    If there are new features (minor version of lightroom), will not be available for the stand-alone version before the next major release?

    Thanks for your help

    My understanding is that LR6 will continue to receive bug fixes and new camera support updates, but not feature/news which receives from the CRD. See question 2 below on this post: CC Lightroom / Camera Raw FAQ

  • Hi I godt 2 Questions: 1) my Adobe PhotoShop elements 10.0 for MAC cannot read taken with the new Canon 7 d Mark II camera RAW files. (2) my Photoshop Elements changed from Danish language of German language, how do I put this back?

    Hi I godt 2 Questions: 1) my Adobe PhotoShop elements 10.0 for MAC cannot read taken with the new Canon 7 d Mark II camera RAW files. (2) my Photoshop Elements changed from Danish language of German language, how do I put this back?

    1. you have cr 8.7 or better: use the dng converter or upgrade your pse in v. 13.

    2 mac App Store version is German. Photoshop Elements

  • R12: Copy a group of companies with configurations, metadata and data in the same instance of OA

    The idea was born to a very common condition between the companies IT. pre-sales and pro-ventes groups do various tasks, including the response of the RPF/RFI, PoC, building, Solution architecture, customer demo etc. Ususally they do not have the dedicated application instances, or rather they do not find a sufficient number of cases of applications dedicated to deep study of the road. Every other day a group cries out for an Apps instance and the same gets lift for senior management in short time. It gives a lot of pain to the infrastructure/DBA groups because they fail to meet people like them, due to the limited availability of free nodes, resources, networks and space etc.

    I have a Vision of the R12.1.3 (tell SID = VIS1213) installed on a Linux machine. The box is quite busy with his hearts limited, showing little free memory and the attached SAN has insufficient free space remaining. A group of Oracle Apps pre-sales consultants, says "Group 1", is the use of this.»

    Now the 3 other groups are asking for a R12.1.3 Vision instance separately for different reasons below. Each of them wants the instance again and do not share with others.

    Group 2 for deep study of the road against a critical response to RFP
    Group-3 for the development of a point of contact for a customer demo
    Group 4 for the manufacture of PUK media on some business processes

    In this scenario, I should install 3 distinct Vision of R12.1.3 (using CDs or downloaded zip) or clone VIS1213 in 3 different places with different SIDS, possibly on one or more separated nodes (as above Linux node has insufficient free resources). In this case, the need for available server resources and disk space multiplied by 3, so that DBA maintenance for these 3 new instances is added.

    Hope that I have clear air up to this point.

    Then I was thinking if we have "virtual instances" within an existing instance of Apps, by copying from a vertain org level. First I thought I'd take THE level, but it will not work if an instance of group to work with HRMS claims. We must therefore take business group level. After that we will create the appropriate role and responsibility, user profile options so that the new user can see and work on the new BG and data area down only. It will be like a separate instance to use.
    Benefits of my desired task will be

    -no separate server resource, the required network
    -no additional DBA not involved maintenance
    -no separate required backup plan

    So here it is to create 3 new "virtual instances" right within the same instance of VIS1213. New groups will have same URL, same existing TNS details but 3 credentials different existing access. Each of them would be limited in a way so that they can not see each and other data and can not hurt each and other changes.

    This can be achieved if we can copy an existing group of its activities with org structures, metadata and data, within the same instance. Oralce planning cannot be copied within the same instance configurations.

    What I've done so far was I manually created a new BG, attached an existing sobbing (CoA, Agenda / currency), created a new, copied and modified accounting structure flexfields before fixing, created the new ORGANIZATIONAL unit, and then a new InvOrg of master and a new InvOrg clild, defined the profile MO some GL and HR profiles. Then I extracted finished master and data assignment article category Masters against a master/child existing InvOrg, updated the data for newly created InvOrgs, inserted into tables insterface and ran seeded import conc program element. Except for a few, all data have been loaded into base against new InvOrgs tables.

    Then I tried with master provider (with sites and contacts). A few AP configurations are required, and then data provider (+ contact + site) have been loaded against OR newly created (under new BG) base tables.

    I do not proceed after that. I'm currently looking for ideas from the experts on how to go further.

    Planning is able to create this kind of 'virtual instance' within the same instance of OSTEOARTHRITIS?

    PL nowadays return.

    Thank you and best regards,
    Castelbajac Dhara
    E-mail: [email protected]

    PL don't post duplicate topics - R12: copy a group of companies with org, configurations, metadata & data structures

  • You want to capture update dates, with trigger on a view to refresh quickly materialized. But trigger on MV consider inserting and updates are inserts only.

    Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0 - 64 bit Production

    PL/SQL Release 11.2.0.4.0 - Production

    CORE Production 11.2.0.4.0

    AMT for Linux: Version 11.2.0.4.0 - Production

    NLSRTL Version 11.2.0.4.0 - Production

    I create the structure of the table like that.

    create table test1 (a primary key, b (2) char number, date c, d varchar2 (10), date of e);

    create table test2 (number of ab, cd (2) tank, date of the ef, gh varchar2 (10), date of the ij, kl varchar2 (100));

    Create materialized view log on test1;

    create materialized view fast refresh test1_v on commit in select * from test1;

    I have create a trigger of the sample

    CREATE OR REPLACE TRIGGER test1_trig

    AFTER INSERT OR UPDATE OR DELETE

    ON test1_v

    FOR EACH LINE

    DECLARE

    lr_test2 test2% ROWTYPE;

    lv_error VARCHAR2 (4000);

    BEGIN

    lr_test2. AB: =: NEW.a;

    lr_test2. CD: =: NEW.b;

    lr_test2. GH: =: NEW.d;

    IF THE INSERTION

    THEN

    lr_test2. EF: = SYSDATE;

    lr_test2.IJ: = SYSDATE;

    lr_test2.KL: = 'INSERT ';

    INSERT INTO test2

    VALUES lr_test2;

    ELSIF UPDATE

    THEN

    lr_test2.IJ: = SYSDATE;

    lr_test2.KL: = 'UPDATE ';

    UPDATE test2 = lr_test2 ab WHERE = LINE: OLD.a;

    ELSIF REMOVAL

    THEN

    DELETE FROM test2

    AB = WHERE: old.a;

    END IF;

    EXCEPTION

    WHILE OTHERS

    THEN

    lv_error: = SQLERRM;

    INSERT INTO XXDOMINO_FG_DATA_LOAD_ERROR

    VALUES ('test1_trig',

    : OLD.a,.

    "test1_trig,"

    LV_ERROR,

    SYSDATE);

    COMMIT;

    END test1_trig;

    /

    So, if check you my code,.

    When I insert EF = SYSDATE, IJ = SYSDATE.

    Update EF is not changed, IJ = SYSDATE.

    So I like to capture their insertion and update dates.

    But if updates or insert arrives on the materialized table. The trigger themselves as an INSERT only.

    So how do you capture the updates?

    I use the statemnet with out merger with performance and also able to capture the update dates.

    CREATE OR REPLACE TRIGGER test1_trig_merge

    AFTER INSERT OR UPDATE OR DELETE

    ON test1_v

    FOR EACH LINE

    DECLARE

    lr_test2 test2% ROWTYPE;

    lv_error VARCHAR2 (4000);

    BEGIN

    IF THE REMOVAL

    THEN

    DELETE FROM test2

        AB = WHERE: old.a;

    ELSIF INSERTION

    THEN

    MERGE INTO test2 one

    B using (SELECT 1 FROM DUAL)

    WE (ab =: new.a)

    WHEN MATCHED

    THEN

    UPDATE the VALUE ab =: NEW.a.

    CD =: NEW.b,

    GH =: NEW.c

    IJ = SYSDATE,

    KL = "Update"

    AB WHERE =: old.a

    WHEN NOT MATCHED

    THEN

    INSERTING VALUES (: NEW.a,)

    : NEW.b,.

    : NEW.c.

    : NEW.d,.

    : NEW.e,.

    "INSERT");

    END IF;

    EXCEPTION

    WHILE OTHERS

    THEN

    lv_error: = SQLERRM;

    INSERT INTO XXDOMINO_FG_DATA_LOAD_ERROR

    VALUES ('test1_trig',

    : OLD.a,.

    "test1_trig,"

    LV_ERROR,

    SYSDATE);

    END test1_trig_merge;

    /

    DISPLAY ERRORS;

  • Dynamic action for validation of date with the notification message plugin

    Hi all

    Someone help me please with dynamic action for validation of date with the message notification plugin. I have a form with two elements of the date picker control and message notification plugin.

    The requirement first user selects the exam is finished and then selects the date. So, if the date is greater than the date of the examination is over + 2 years then doesn't trigger the message notification plugin. I tried to create that dynamic action on the date picker date that triggers the scheduled issue notification message but I want to make conditional, I mean displays the message only if date of the selected is greater than the date of the exam is finished more than 2 years.

    In terms simple, notification is displayed only if provided is superior to (date of the exam is completed + 2 years).

    I use oracle apex 4.0 version and oracle 10g r2 database. I tried to reproduce the same requirement in my personal workspace. Here are the details. Please take a look.

    Workspace: raghu_workspace

    username: orton607

    password: orton607

    APP # 72193

    PG # 1

    Any help is appreciated.

    Thanks in advance.

    Orton.

    You can get the value of the date of entry:

    $(ele) .datePicker ('getDate');

    So what to add functions such as:

    function validateNotification (d1, d2) {}

    Date1 var = $(d1) .datepicker ('getDate');

    date2 var = $(d2) .datepicker ('getDate');

    if(date1 && date2) {}

    return ((date2.getTime()-date1.getTime())/(1000*24*60*60))>(365*2);

    } else {}

    Returns false;

    }

    }

    The logic based on setting (I have two years from years of 365 days preceding)

    Then in the D.A. specify a JavaScript expression as:

    validateNotification ('P2_REVIEW_COMPLETED', this.triggeringElement.id)

    Refer to page 2 for example.

  • Need to create a new line in the table with the same data as the primary key, but new PK

    Hello gurus,

    I have a table with a column as a primary key, I need to create a new row in the table, but with the same data in one of the lines, but with different primary keys, focus a double row with key primary diferent...

    Any ideas of how it can be done without much complication?

    Thanks in advance for your answer.

    Agress,
    Karim idrissi

    user9970447 wrote:
    Hello gurus,

    I have a table with a column as a primary key, I need to create a new row in the table, but with the same data in one of the lines, but with different primary keys, focus a double row with key primary diferent...

    Any ideas of how it can be done without much complication?

    Thanks in advance for your answer.

    Agress,
    Karim idrissi

    something like

    insert into mytable values ('literal for new pk',
                                           select non-pk-1,
                                                    non-pk-2,
                                                    non-pk-n
                                           from mytable
                                           where pk-col = 'literal for existing pk')
    
  • the camera shutter sound cannot be silent with the mute button on my phone i 6 s

    the camera shutter sound cannot be silent with the mute button on my phone i 6 s

    Depending on where you purchased your phone, this is not possible, because of legislation in these countries that regulate this feature.

    In all other cases, try to force reboot the phone by holding down the button sleep and home for 10 seconds, until the Apple logo comes back again. You won't lose data, but it can cure some problems after installing new software or applications.

    In the case where this does not work, restore the phone:

    Use iTunes to restore your device iOS to factory settings

  • How to open multiple files with the same extension in one program from the Explorer

    I frequently receive several JPG (or whatever extension) files to my clients.  On Windows XP, I could just highlight the files I want to open, and then click Open.  They would be so open to 1 program cascading.  This made it easy when comparing many images.  If I do the same thing in Windows 7, it opens the default program several times and puts 1 image of each open program.  It is Paint Shop Pro in my case.  Thus, instead of so-called images 5 open cascading in Paint Shop Pro... the computer open Paint Shop Pro 5 times with 1 image of each open version of the program.  I tried this search like crazy, but cannot find the right thread for an answer.  Most of the threads are on the opening of the different file types.  My question is only about the opening of multiple files with the same exact file inside 1 free program extension.

    Is this the same version of Paint Shop?

    One thing you might try is to open Paint Shop, then select and drag all the files in this window of the paint shop.  Various programs to manage this type of action differently from the DDE, but it might give you the expected results.

  • Create triggers in the table, sequence, insert and update with "model"?

    It must be of rtfm, trial and error thing but you wanted to ask, is it possible to have models or similar automation for the following scenario:

    1.), I add the table to the logic model

    2.) Using glossary I transform a relational model that was recovered / synchronized with the data dictionary

    3.) then I have the new table to add

    -but

    I would then have auto-DDL of to be synchronized to database:

    -create sequence for the id column

    -create table

    -create indexes for the id column pk

    -Create triggers for insert and update

    -l' idea is to have db_created_dt and db_modified_dt defined in the table, so that each table has them to the fields of record etc.

    -activate the triggers

    Each of them following the same naming convention.

    Similarity with approx. generator Apex workshop utils sql create table of the copy paste "excel" that creates 'id' - column + sequence and insert the trigger.

    rgrds Paavo

    Hi Paavo,

    most of the steps can be made in one or other way

    -create sequence for the id column

    -create table

    -create indexes for the id column pk

    If you want to start in the logic model and you don't want to have the ID column in the logic model and select 'Create the surrogate key' checkbox in the dialog entity - you will get an identity column in the relational model and the version of database and settings in ' preferences > Data Modeler > model > physics > Oracle "you can set the sequence generation and the trigger for taking in load.

    fields of record defined in the table, so that each table has them

    You can add the same set of columns in all tables with the transformation script 'model of Table... ».

    You can also look here Oracle SQL Developer Data Modeler 4.1 user - defined DDL generation using transformation scripts

    to see how to grant your DDL generation using the transformation script. DM comes with example to generate separate tables of logging and triggers. You can create your build script of triggers that support logging in these common columns.

    Philippe

Maybe you are looking for