tags:

views:

179

answers:

5
 $result = mysql_query("INSERT INTO categories (cd_title , cd_link )
                       VALUES ('$docuTitle','$linkTitle')");

This works fine, but i want to update these values in another field in same table. Once these two are successful i need to pass return values.

$result = mysql_query("UPDATE into categories WHERE c_name = '$catID'");

I know that i am not using mysql escape or PDO...

A: 

For one thing, the UPDATE syntax should be:

UPDATE categories SET column_name = 'data' WHERE c_name = `$catID`
John Rasch
A: 

Try:

"UPDATE categories SET cd_title = '$docuTitle', cd_link = '$linkTitle' WHERE c_name = '$catID'"

Also see the MySQL reference, and beware of SQL injection attacks (search this site for "SQL injection" for some hooks)

skrebbel
A: 

The syntax for UPDATE should be:

UPDATE categories SET <colname> = <value> WHERE c_name = '$catID'
Matt Bridges
A: 

I would first insert the row, then do the update (Although I'm not sure of your syntax above), both within a transaction.

Rich
+1  A: 

Please look at mysql-good-way-to-insert-a-row-if-not-found-or-update-it-if-it-is-found for a explanations and pointers to replace into syntax

lexu