mike12255 Posted January 18, 2009 Share Posted January 18, 2009 I got the current code: if($session->isAdmin()){ print"  -<A href='deletetopic.php?id=$id'>Delete Topic "; $query = "SELECT locked FROM forumtutorial_posts WERE postid = $id"; $result = mysql_query($query); print $result; if ($result < 1){// if locked is set to 0 (unlocked) print"  -<A href='locktopic.php?id=$id'>Lock Topic"; }else{//otherwise show unlock print"  -<A href='unlocktopic.php?id=$id'>Unlock Topic"; } } I know that locked for the postid it should be using (13) is set to 1 so it should show unlock topic, but instead it shows lock topic. Can anyone see why? Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 18, 2009 Share Posted January 18, 2009 "$result" is a database result set. You can't print it to the page and it's value is meaningless for comparison purposes. You need to extract the records from the result set. Also, you aren't even using closing tags on your anchors. Sloppy code will always be errror prone. Try this: if($session->isAdmin()) { $query = "SELECT locked FROM forumtutorial_posts WERE postid = $id"; print "Query: $query<br /><br />\n"; //For debugging only $result = mysql_query($query) or die(mysql_error());; $record = mysql_fetch_assoc($result); print"  -<A href='deletetopic.php?id=$id'>Delete Topic</a> \n"; if ($record['locked'] < 1) { // if locked is set to 0 (unlocked) print"  -<A href='locktopic.php?id=$id'>Lock Topic</a>\n"; } else { //otherwise show unlock print"  -<A href='unlocktopic.php?id=$id'>Unlock Topic</a>\n"; } } Quote Link to comment Share on other sites More sharing options...
mike12255 Posted January 18, 2009 Author Share Posted January 18, 2009 Is the following line suposed to have two ";"? $result = mysql_query($query) or die(mysql_error());; I tried it with both there and with only one and got the following error displayed on my page. Quote Link to comment Share on other sites More sharing options...
revraz Posted January 18, 2009 Share Posted January 18, 2009 It should be WHERE not WERE in your query. And only 1 ; Quote Link to comment Share on other sites More sharing options...
mike12255 Posted January 18, 2009 Author Share Posted January 18, 2009 Thought it was only one, thanks mates 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.