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 :)

remove comma (,) before where

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

Hey evstevemd, thanks for the reply.

I'm trying to update multiple values though?

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