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. Link to comment https://forums.phpfreaks.com/topic/44681-solved-not-getting-proper-error-message/ Share on other sites More sharing options...
papaface Posted March 28, 2007 Share Posted March 28, 2007 if (!$result) Dont you mean: if (!$check) ? Link to comment https://forums.phpfreaks.com/topic/44681-solved-not-getting-proper-error-message/#findComment-216977 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 Link to comment https://forums.phpfreaks.com/topic/44681-solved-not-getting-proper-error-message/#findComment-216979 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>'); Link to comment https://forums.phpfreaks.com/topic/44681-solved-not-getting-proper-error-message/#findComment-216981 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 Link to comment https://forums.phpfreaks.com/topic/44681-solved-not-getting-proper-error-message/#findComment-216982 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.