I am trying to update multiple rows in my database using php and mysql.

Here is my php mysql statment:

$sql = "UPDATE book_store SET".
"title = '$_POST[title]', isbn = '$_POST[isbn]', price = '$_POST[price]', quantity = '$_POST[quantity]' ".
"WHERE ID = '$_POST[id]' ";

Here is my Error:

Error: 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 '= 'PHP and MySQL Web Development', isbn = '0672329166', price = '34.43', quantit' at line 1

What am I doing wrong?

Recommended Answers

All 4 Replies

hai singularity~,

i think if you echo your $sql variable before executing,it display's as follows

UPDATE book_store SETtitle = '$_POST[title]', isbn = '$_POST[isbn]', price = '$_POST[price]', quantity = '$_POST[quantity]' WHERE ID = '$_POST[id]'

there is no space between 'SET' keyword and 'title'

so please provide space between 'SET' keyword and title

that might be the one giving the error i think

please check it once i guess right or not

let me know the status

Thanks!

There was no space between SET and title.

I needed another eye.

I needed another eye

what does it means.could you expalin?

let me know

happy coding

Member Avatar for diafol

Another pair of eyes = somebody else to take a fresh look at something, as you're going around in circles and continually looking at something from the same point of view.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.