Reputation: 1
This code keeps erroring.
Error Message: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/soulz/public_html/inbox.php on line 19
Here is the code:
mysql_query("UPDATE `messages` SET message_title = '[NO SUBJECT]' WHERE `message_id`=$row['message_id']");
Upvotes: 0
Views: 119
Reputation: 1382
It seems message_id is integer
, so you can fix that error with a best practice.
mysql_query("UPDATE `messages` SET message_title = '[NO SUBJECT]'
WHERE `message_id`=" . intval($row['message_id']));
You can use strval()
for strings. Both functions are detailed in intval() manual page and strval() manual page.
Upvotes: 0
Reputation: 85458
Use curly braces:
mysql_query("UPDATE `messages` SET message_title = '[NO SUBJECT]'
WHERE `message_id`={$row['message_id']}");
Upvotes: 3
Reputation: 476990
Don't put apostrophes around the field name:
mysql_query("UPDATE `messages` SET message_title = '[NO SUBJECT]'
WHERE `message_id`=$row[message_id]");
^^^^^^^^^^
Inside quoted strings, you cannot use additional quotation marks for array field names. There's an alternative, more elaborate syntax involving braces if you have a very complicated array expression, but you don't need that here.
Upvotes: 2