NYCPHP Meetup

NYPHP.org

[nycphp-talk] inserting data into MySQL table.

PaulCheung paulcheung at tiscali.co.uk
Mon Jul 23 16:50:35 EDT 2007


Hi everybody,

Thanks for the information, unfortunately for me there are no arrays being 
used. The names used are solely the names of each individual column/field in 
the table. I have already tried all the suggestions to no avail. That is why 
I hardcoded a version of my insert-data-into-table and once I knew it worked 
I substituted all the hardcoded fields with $_POST in place of the 
hardcoding, I then cut and pasted in each field the corresponding  hardcoded 
value and just before writing the record. I echoed the record values and all 
appears to be well. Then via the MySQL Monitor I check to see if the record 
had been written and found that nothing has happened. Please forgive me if I 
appear to be ungrateful, which is not the case I am just frustrated. 
Especially after proving that one version of my insert-data-into-table 
(hardcoded) worked and a version of my insert-data-into-table works with a 4 
column table (a different table) and will not work with a version using as 
input data the values of the hardcoded version. I knows the fault lays with 
me but I cannot see it.

Paul
----- Original Message ----- 
From: "csnyder" <chsnyder at gmail.com>
To: "NYPHP Talk" <talk at lists.nyphp.org>
Sent: Monday, July 23, 2007 7:04 PM
Subject: Re: [nycphp-talk] inserting data into MySQL table.


> On 7/23/07, Jon Baer <jonbaer at jonbaer.com> wrote:
>> Id guess that one of your data types (or more) is still not valid for
>> the type declared but ~not sure if you know this~ but you can add
>> column names before your query ...
>>
>> INSERT INTO my_table (col1_name, col2_name) VALUES (col1_value,
>> col2_value) // Try a few values up until you error out
>>
>
> I find it even less confusing to use the SET variant that makes
> INSERTs look like UPDATEs:
>
> INSERT INTO my_table SET col1_name=col1_value, col2_name=col2_value;
>
>
> -- 
> Chris Snyder
> http://chxo.com/
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php 



More information about the talk mailing list