0

Hi, i'm trying to update a mysql table with values, and i get this 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 'WHERE StockID= 23' at line 1.

Here is my code.

$sql="UPDATE stock SET HDDType='$hddtype', HDDConnection='$hddconnection', HDDSize='$hddsize', Make='$make', Model='$model', Comments='$comments', Date='$date', WHERE StockID= $id";

And here is my echoed query:

UPDATE stock SET HDDType='internal', HDDConnection='ide', HDDSize='1000', Make='Hitachi', Model='HDT721010SLA361', Comments='', Date='05/08/11', WHERE StockID= 23

Thanks guys :)

4
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by ddymacek
0

Thanks, all works now!

I'm just trying to clean the code up a bit, and I get a syntax error with this.

$sql="UPDATE stock WHERE StockID= '$id' (Category, HDDType, HDDConnection, HDDSize, Make, Model, Comments, Date)
VALUES
('$type','$hddtype','$hddconnection','$hddsize','$_POST[make]','$_POST[model]','$_POST[comments]', '$date')";

I'm grateful for your help :)

This is the error i'm getting:

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 'WHERE StockID= '23' (Category, HDDType, HDDConnection, HDDSize, Make, Model, Com' at line 1

Edited by azhpool: n/a

0

Hey evstevemd, thanks for the reply.

I'm trying to update multiple values though?

0

then use your original query, minus the ,

$sql="UPDATE stock SET HDDType='$hddtype', HDDConnection='$hddconnection', HDDSize='$hddsize', Make='$make', Model='$model', Comments='$comments', Date='$date' WHERE StockID= $id";
// that's about as 'clean' as your going to get.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.