Page 1 of 1

Record is not recoreded in MYSQL

Posted: Tue Jun 16, 2009 6:39 am
by becky-atlanta
I created a new table in a database. The old table was working fine. I modified the same code but substitute with the new table's name and data fields. When I submitted the form on the web page, there was no error. When I checked the table, there was no data. Any suggestions?

Code: Select all

$hostname = "MYSQLHOST";    
mysql_connect($hostname, $username, $password) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());
mysql_query("INSERT INTO camper_information (camper_lastname, camper_firstname, date_of_birth, grade, school, address, city, state, zip, camper_phone, week1, week2, week3, week4, week5, week6, father_name, father_cell, father_work, father_email, mother_name, mother_cell, mother_work, mother_email, emergency_name1, emergency_home1, emergency_cell1, emergeny_name2, emergency_home2, emergency_cell2, doctor_name, doctor_phone, allergies, treatments, medications, mecdical_others, dismissal_mon, dismissal_tue, dismissal_wed, dismissal_thu, dismissal_fri, handbook, permission, submitter)
VALUES ('$camper_lastname', '$camper_firstname', '$date_of_birth', '$grade', '$school', '$address', '$city', '$state', '$zip', '$camper_phone', '$week1', '$week2', '$week3', '$week4', '$week5', '$week6', '$father_name', '$father_cell', '$father_work', '$father_email', '$mother_name', '$mother_cell', '$mother_work', '$mother_email', '$emergency_name1', '$emergency_home1', '$emergency_cell1', '$emergeny_name2', '$emergency_home2', '$emergency_cell2', '$doctor_name', '$doctor_phone', '$allergies', '$treatments', '$medications', '$mecdical_others', '$dismissal_mon', '$dismissal_tue', '$dismissal_wed', '$dismissal_thu', '$dismissal_fri', '$handbook', '$permission', '$submitter')");
 

Re: Record is not recoreded in MYSQL

Posted: Tue Jun 16, 2009 7:01 am
by it2051229
can you add a "or die(mysql_error())" on your query?

like:

mysql_query($myQuery) or die(mysql_error());

and run it again...

Re: Record is not recoreded in MYSQL

Posted: Tue Jun 16, 2009 7:23 am
by divito
Double check each field for the form and database. Ensure you aren't overlooking one or that the spelling might have changed.

Re: Record is not recoreded in MYSQL

Posted: Wed Jun 17, 2009 9:25 pm
by becky-atlanta
Thanks for pointing this out, Divito!

I started a new table with a few fields and it worked. Then I added 10 fields at a time. So I am sure I did not spell everything exactly the way they should be in the first table. This is a good learning exercise. I'll know what to do when I am building a large table again.