JJBlaha Posted November 15, 2006 Share Posted November 15, 2006 if($read == '0') {$sql2 = "UPDATE privatemessages SET read = '1' WHERE id='$id'";$result2 = @mysql_query($sql2,$connection);if($result2) {echo "great success!";} else {echo "you fail!";}}outputs you fail!i know the id whatever is there, and i know the read is set to 0 there so why doesnt the script work? Quote Link to comment Share on other sites More sharing options...
SharkBait Posted November 15, 2006 Share Posted November 15, 2006 Change it to read:[code]<?php$result2 = mysql_query($sql2, $connection) or die("MySQL Error: <br />{$sql2}<br /> ". mysql_error());?>[/code]the die() section will stop the rest of the script and the mysql_error() will output what is wrong if its a MySQL issue. Quote Link to comment Share on other sites More sharing options...
JJBlaha Posted November 15, 2006 Author Share Posted November 15, 2006 MySQL Error:UPDATE privatemessages SET read = '1' WHERE id='7'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 'read = '1' WHERE id='7'' at line 1is what i get. Quote Link to comment Share on other sites More sharing options...
trq Posted November 15, 2006 Share Posted November 15, 2006 I assume $read is NOT a string.[code=php:0]if($read == 0) {[/code] Quote Link to comment Share on other sites More sharing options...
SharkBait Posted November 15, 2006 Share Posted November 15, 2006 read is a function of MySQLEnclose read with backticks (next to the 1 key) [code]<?phpUPDATE privatemessages set `read` = '1' WHERE id = '{$id}'?>[/code] Quote Link to comment Share on other sites More sharing options...
JJBlaha Posted November 15, 2006 Author Share Posted November 15, 2006 Thanks that worked beautifully :) If i had chosen something other than read such as r121 i would not have had to do that? Quote Link to comment Share on other sites More sharing options...
trq Posted November 15, 2006 Share Posted November 15, 2006 [quote]If i had chosen something other than read such as r121 i would not have had to do that?[/quote]yeah... didn't even pick up on that. read is a reserved word in MySql. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.