ecabrera Posted April 11, 2012 Share Posted April 11, 2012 I dont why this does not insert into my db $query = mysql_query(" INSERT INTO `reviews`(``, `author`, `date`, `picture`, `review`) VALUES ('',$author,$date,$picture,$review)"); Quote Link to comment https://forums.phpfreaks.com/topic/260754-insert-inot/ Share on other sites More sharing options...
Psycho Posted April 11, 2012 Share Posted April 11, 2012 Well, you aren't checking for an error, so yeah it would be difficult to figure it out. But, I see at least one problem. You are defining an empty field at the beginning of the field list. That's definitely a problem. Also, I don't know what the values of those variables are, but unless they have the insert values enclosed in quote marks (assuming these aren't numerical values) that will cause a problem as well. Create your query as a string variable. Then if there is an error, output the error and the full query for debugging purposes. Also, I like to format my queries such that the structure adds context. $query = "INSERT INTO `reviews` (`author`, `date`, `picture`, `review`) VALUES ('$author', '$date', '$picture', '$review')"; $result = mysql_query($query); if(!$result) { die("Query Failed:<br>{$query}<br>Error: " . mysql_error()); } Quote Link to comment https://forums.phpfreaks.com/topic/260754-insert-inot/#findComment-1336477 Share on other sites More sharing options...
ecabrera Posted April 11, 2012 Author Share Posted April 11, 2012 show i leave the id empty Quote Link to comment https://forums.phpfreaks.com/topic/260754-insert-inot/#findComment-1336479 Share on other sites More sharing options...
litebearer Posted April 11, 2012 Share Posted April 11, 2012 If it is auto-increment, then yes Quote Link to comment https://forums.phpfreaks.com/topic/260754-insert-inot/#findComment-1336484 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.