Insert into MySQL not working
Posted: Sun Mar 23, 2003 8:49 pm
Hello,
I am new to PHP and looking for help.
I have a form that posts data to the code below to do an insert. Part of the form page also checks to see if this record all ready exists, if it does then it performs an update instead of an insert.
I am getting a mysql_error code of 0 which I thought meant everything was ok, yet I don't get any records in the db. So now I am confused.
any help would be appreciated.
The code to insert or update the DB is as follows:
With mysql_error() I get zero. Yet I get no records added to the DB.
Any help would be appreciated. Thanks!
Jeff
I am new to PHP and looking for help.
I have a form that posts data to the code below to do an insert. Part of the form page also checks to see if this record all ready exists, if it does then it performs an update instead of an insert.
I am getting a mysql_error code of 0 which I thought meant everything was ok, yet I don't get any records in the db. So now I am confused.
any help would be appreciated.
The code to insert or update the DB is as follows:
Code: Select all
// Make Connection to the DB
$conn=mysql_connect("localhost","admin","adm1n03");
mysql_select_db("wedding_db",$conn);
if($nr == "no"){
echo "It states nr is no.";
echo "Looking at doing an update on the record here...";
$mysql_query = "UPDATE bride set gatekeeper_id = $gatekeeper_id, fname=$fname, mname=$mname, lname=$lname, city_born=$city_born, state_born=$state_born, date_born=$date_born, current_job=$current_job, img1=$img1, img1_text=$img1_text, img2=$img2, img2_text=$img2_text, img3=$img3, img3_text=$img3_text";
echo mysql_errno() . ": " . mysql_error() . "\n";
}
else{
echo "It states nr is yes.";
echo "Looking at doing an insert into the db here...";
$mysql_query = "INSERT INTO bride (gatekeeper_id, fname, mname, lname, city_born, state_born, date_born, current_job, img1, img1_text, img2, img2_text, img3, img3_text) VALUES ('$gatekeeper_id', '$fname', '$mname', '$lname', '$city_born', '$state_born', '$date_born', '$current_job', '$img1'.''$img1_text', '$img2', '$img2_text', '$img3', '$img3_text')";
echo mysql_errno() . ": " . mysql_error() . "\n";
}
include ("footer.html");
?>Any help would be appreciated. Thanks!
Jeff