Drezard Posted February 10, 2007 Share Posted February 10, 2007 Okay heres my code: $query = "SELECT * FROM user_chars WHERE user='$user' AND `character`='1'"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $count = mysql_num_rows($result); Now in my Database under character it is 1. The only problem is when i run this script, count = 0. The variable $user contains the right stuff what else could it be? - Cheers, Daniel Quote Link to comment Share on other sites More sharing options...
paul2463 Posted February 10, 2007 Share Posted February 10, 2007 if the character is a number and not text then remove the single ticks from around the 1 <?php $query = "SELECT * FROM user_chars WHERE user='$user' AND `character`=1"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $count = mysql_num_rows($result); ?> try that. Quote Link to comment Share on other sites More sharing options...
Drezard Posted February 10, 2007 Author Share Posted February 10, 2007 so when do i use ` and when do i not use them? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 10, 2007 Share Posted February 10, 2007 You use ` when the word is a reserved word, such as a field called order. It is a bad idea to have your fields named that way, so you shouldn't generally need to use them. character is a reserved word: http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html You use ' to surround a string. It shouldn't hurt to put single quotes around numbers, as you might get unexpected content, so it can help stop errors. 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.