Jump to content

syntax error...


m00nz00mer

Recommended Posts

can someone tell me what is wrong with this code...

 

$formQueryComment = "INSERT INTO nbc_bookreview (reviewText) VALUES ('$formComment') WHERE bookISBN='".$_GET['bookID']."'"; mysql_query($formQueryComment) or die(mysql_error());

 

im getting...

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE bookISBN='0201708574'' at line 1

 

Link to comment
Share on other sites

basically this is what im trying to do...

 

//Form Processing

if(isset($_POST['submitted'])) {

 

$formUser = trim($_POST['userName']);

  $formPassword  = trim($_POST['passWord']);

  $formName = trim($_POST['fullName']);

  $formComment = trim($_POST['comments']);

 

$formQuery = "INSERT INTO nbc_user (userID, UserName) VALUES ('$formUser', '$formName')"; mysql_query($formQuery) or die(mysql_error());

$formQueryComment = "INSERT INTO nbc_bookreview (reviewText) VALUES ('$formComment') WHERE bookISBN = '".$_GET['bookID']."'"; mysql_query($formQueryComment) or die(mysql_error());

 

//Refresh the page

echo "<meta http-equiv='refresh' content='1'>";

 

}

 

Link to comment
Share on other sites

I suspect you don't understand the idea behind INSERTing data in a table. When you INSERT, you create an entirely new row, and WHERE clauses aren't used except when you're working with pre-existing data.

 

If you're trying to create a new row with a book's review, you're probably going to want something along these lines:

 

INSERT INTO nbc_bookreview (reviewText, bookISBN) VALUES ('$formComment', '$bookID');

 

And when you're describing to us what you want to do, you need to describe it in your own words, not just show us your code. Your code may be (in this case, it is) faulty, so we can't tell what it is you're trying to do.

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.