Page 1 of 1

Update wont work...

Posted: Sat Apr 22, 2006 7:06 pm
by BigAbe
Aloha again everyone,

I have two similar queries (INSERT and UPDATE), and only the INSERT works...

Works:

Code: Select all

$runquery = mysql_query("INSERT INTO categories (catName) VALUES ('$catAdd')");
Does not Work:

Code: Select all

$runquery = mysql_query("UPDATE categories SET catActive = 0 WHERE catID = $catdeactivate)");
I have tried inputing the query directly into mySQL through phpMyAdmin, and the UPDATE query is performed perfectly.

I have debugged and ensured that the appropriate variables have been passed.

Any help would be awesome!

Mahalo,

-- Abe --

Posted: Sat Apr 22, 2006 7:29 pm
by feyd
What is $catdeactivate in this particular case?

Posted: Sat Apr 22, 2006 7:36 pm
by BigAbe
feyd wrote:What is $catdeactivate in this particular case?

Code: Select all

$catdeactivate=$_POST['catdeactivate'];
In this instance catdeactivate is an INT.

Posted: Sat Apr 22, 2006 9:35 pm
by feyd
what does mysql_error() say?

Posted: Sat Apr 22, 2006 10:01 pm
by John Cartwright
you have a parse error

Code: Select all

$runquery = mysql_query("UPDATE categories SET catActive = 0 WHERE catID = $catdeactivate)");
should be

Code: Select all

$runquery = mysql_query("UPDATE categories SET catActive = 0 WHERE catID = '$catdeactivate'");
Notice you had an extra bracket and quote. Don't forgot to quote the strings as well.

Posted: Mon Apr 24, 2006 2:47 am
by tonera
$runquery = mysql_query("UPDATE categories SET catActive = 0 WHERE catID = $catdeactivate)");

what's the red word?

Posted: Wed Apr 26, 2006 1:10 pm
by BigAbe
Jcart wrote:you have a parse error

Code: Select all

$runquery = mysql_query("UPDATE categories SET catActive = 0 WHERE catID = $catdeactivate)");
should be

Code: Select all

$runquery = mysql_query("UPDATE categories SET catActive = 0 WHERE catID = '$catdeactivate'");
Notice you had an extra bracket and quote. Don't forgot to quote the strings as well.
Thanks a million!

So in the future, I just need to keep spaces between all of the operators?

Thanks again!

Posted: Wed Apr 26, 2006 1:34 pm
by John Cartwright
you need to quote strings in a query, plus you had a bracket that wasn't supposed to be there ;)

And yes, it is best if you space your operators.