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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.