Algorath Posted June 16, 2011 Share Posted June 16, 2011 $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. Quote Link to comment https://forums.phpfreaks.com/topic/239530-table-doesnt-exist/ Share on other sites More sharing options...
Muddy_Funster Posted June 16, 2011 Share Posted June 16, 2011 Could be a field name error - like case mistake on User or using User instead of Users. Check the field name first. Quote Link to comment https://forums.phpfreaks.com/topic/239530-table-doesnt-exist/#findComment-1230517 Share on other sites More sharing options...
fugix Posted June 16, 2011 Share Posted June 16, 2011 what is the exact error that you receive when using $charinfo="SELECT name from `user_stats` WHERE User='$sname'"; $char=mysql_result(mysql_query($charinfo),0) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/239530-table-doesnt-exist/#findComment-1230526 Share on other sites More sharing options...
The Little Guy Posted June 16, 2011 Share Posted June 16, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/239530-table-doesnt-exist/#findComment-1230796 Share on other sites More sharing options...
Algorath Posted June 17, 2011 Author Share Posted June 17, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/239530-table-doesnt-exist/#findComment-1230946 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.