NYCPHP Meetup

NYPHP.org

[nycphp-talk] inserting data into MySQL table.

David Krings ramons at gmx.net
Mon Jul 23 17:13:02 EDT 2007


PaulCheung wrote:
> 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


You said you tried everything, so you did echo the query string and 
copied that into the MySQL query browser and that adds the record? If 
yes, you are looking at some db connection error (alhtough PHP should 
throw a fit there). Maybe you sent the records to the wrong 
table/database? That happened to me once while testing on the production 
side. I just copied all the working scripts over, including the one that 
connects to the test database.
So, you want to look for an error somewhere rather than just at the 
result. And you limited the error down to the variable values from 
$_POST. Can you post the query in the exact form as you plan to send it 
to the database in an email to the list? It is possible that a few dozen 
eyes may see more than yours (no, I'm not calling you blind...I hope you 
know what I mean).

David



More information about the talk mailing list