psychohagis Posted March 28, 2007 Share Posted March 28, 2007 I have the following query/code thing. $check = @mysql_query("SELECT id, username FROM users WHERE rank='$rank'"); if (!$result) { $mysql_error = mysql_error(); exit('<p>Error performing query: ' . $mysql_error . '</p>'); When i run it it tells me theres an "error performing query:" but then does print out the mysql_error I dont understans this cos I use this sam bit of code on other pages (except with different querys) and if theres a problem with me query it tells me what it is. Quote Link to comment Share on other sites More sharing options...
papaface Posted March 28, 2007 Share Posted March 28, 2007 if (!$result) Dont you mean: if (!$check) ? Quote Link to comment Share on other sites More sharing options...
psychohagis Posted March 28, 2007 Author Share Posted March 28, 2007 Ok Ive changed that but now when I run the following: $check = @mysql_query("SELECT id, username FROM users WHERE rank=$rank"); if (!$check) { $mysql_error = mysql_error(); exit('<p>~ Error performing query: ' . $mysql_error . '</p>'); } it says "Error performing query: Unknown column 'chairman' in 'where clause'" which makes no sense cos i dont ask for column 'chairman' This query is asking it to find $rank (which happens to be 'chairman' here) in column rank Quote Link to comment Share on other sites More sharing options...
papaface Posted March 28, 2007 Share Posted March 28, 2007 Well for a start you should never use the suppression sign @ - its bad coding. i dont understand why you are making this so long winded. Try this though: $check = mysql_query("SELECT id, username FROM users WHERE rank='{$rank}'") or die("<p>Error performing query: " . mysql_error() . "</p>"); ^^ does the same as $check = @mysql_query("SELECT id, username FROM users WHERE rank='$rank'"); if (!$result) { $mysql_error = mysql_error(); exit('<p>Error performing query: ' . $mysql_error . '</p>'); Quote Link to comment Share on other sites More sharing options...
psychohagis Posted March 28, 2007 Author Share Posted March 28, 2007 oh ok ill try that im only doing it like that because thats the way i learnt to do it 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.