Jump to content

Update Statement Not Working


Guest FirefoxRocks
 Share

Recommended Posts

Guest FirefoxRocks

This might be a stupid question but I don't understand why this isn't working:

UPDATE `table` SET `title`="Facebook Connect" && `author`="1" && `assoc`='nw' && `assocId`='8' && `content`='<p>Facebook Connect is cool.</p>\r\n<p>It helps you attract more users.</p>' && `tags`='social networking, facebook' WHERE `id`=5 LIMIT 1  ;

MySQL doesn't return an error, but nothing updates, except that the title becomes 0.I have tried quoting the `id` value and removing LIMIT 1; but the result is the same. I have tried copying the exact code from phpMyAdmin to my process page but the result is the same, and I also tried executing my code in phpMyAdmin but the same thing happens!At first I thought it was one of my variables that got emptied or something but now I realize that putting text in there doesn't change it.MySQL gives this syntax for the UPDATE statement:

UPDATE [LOW_PRIORITY] [iGNORE] table_reference SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ... [WHERE where_condition] [ORDER BY ...] [LIMIT row_count]

What am I doing wrong?

Edited by FirefoxRocks
Link to comment
Share on other sites

You're using the logical && operator. So you're giving it a logical expression to set title to. Apparently it's evaluating to false, which is why it gets a value of 0. Review the syntax for UPDATE queries, you don't need to use AND to separate the columns.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...