Jump to content

INsert inot


ecabrera

Recommended Posts

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());
}

Link to comment
https://forums.phpfreaks.com/topic/260754-insert-inot/#findComment-1336477
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.