Jump to content

Table doesn't exist


Algorath

Recommended Posts

$charinfo="SELECT name from `user_stats` WHERE User='$sname'";
$char=mysql_result(mysql_query($charinfo),0);

 

What this should do, and actually does in other parts of my code, is grab the name and then throw it into $char. Username and Char name are different.

The result is table does not exist. HOWEVER! The catch is, the output for the error message is "Table 'DB.$sname' doesn't exist"(DB is my actual database name and $sname is the actual called name, not the variable itself.) which is confusing the heck out of me. I haven't been able to find any reason why that would be happening. This is in MySQL 5.0, however I'm not sure if it's applicable or not. I'm sure this is just a foolish error on my part. However, any help would be greatly appreciated.

Link to comment
Share on other sites

don't use mysql_query inside of another function, I have it can cause problems (it has happend to me).

 

$charinfo="SELECT name from `user_stats` WHERE User='$sname'";
echo $charinfo; // Check what is being used as a query
$sql = mysql_query($charinfo)or die(mysql_error()); // See what error mysql gave us
$char=mysql_result($sql, 0);

 

edit:

Mysql tables are case sensitive.

Link to comment
Share on other sites

I've managed to track the problem down. As I said in my post, the snippet itself was used a couple other times. I'm using multiple tables and databases, so in calling a different database, I found my errors. At first, upon reviewing my code for the 1000th time, I noticed a missing piece of code calling the correct database. Thanks to all who attempted to solve my woes. This is why I should stop using my own code snippets. I forget about the small stuff. On a side note, when I was reviewing my code, again, I noticed the problem itself was actually below the chunk of code that I posted here. It was just that, in order to get to the erroneous code, the chunk had to be true. Anyway, thanks again for your aid.

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.