php script not inserting data into database
Posted: Thu Aug 04, 2005 4:36 pm
I have a mysql script that should, under all circumstances, insert data into a database. here's the part of the script responsible for the insertion:
Now, you will notice that echo $query is commented out. if I uncomment it, it returns: INSERT INTO reviews (id, epcode, epname, reviewer, review, rating) VALUES ( '', 'FG103', 'Mind Over Murder', 'fds', 'fds', '2' )
All those values are correct for the datatypes of the fields. Also, no error is returned. Everything is outputted ok, but nothing is inserted into the database. is there something simple i'm overlooking? Also, $review and $reviewer do have values.
Code: Select all
if (($reviewer) && ($review)) {
$episode = getepname($epcode);
$username = "*****";
$password = "*****";
$database = "quahog5news_com_-_interactive";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die("Unable to select database");
$query = "INSERT INTO reviews (id, epcode, epname, reviewer, review, rating) VALUES (
'',
'$epcode',
'$episode',
'$reviewer',
'$review',
'$rating'
)";
mysql_query($query);
mysql_close();
//echo $query;
echo "Thank you for submitting a review for the episode " . $episode . ". Please click <b><a href=index.php?p=reviews>here</a></b> to return to the main reviews page, or click <b><a href=index.php?p=reviews&epcode=" . $epcode . ">here</a></b> to see your review!<br><BR><BR><center><h2><a href=index.php?p=reviews><< BACK</a></h2></center>";
} else {
echo "Please fill out all fields before submitting a review.";
halt;
}All those values are correct for the datatypes of the fields. Also, no error is returned. Everything is outputted ok, but nothing is inserted into the database. is there something simple i'm overlooking? Also, $review and $reviewer do have values.