Jump to content

[SOLVED] Not getting proper error message


psychohagis

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.