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 Link to comment https://forums.phpfreaks.com/topic/37880-sql-problems/ 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. Link to comment https://forums.phpfreaks.com/topic/37880-sql-problems/#findComment-181352 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? Link to comment https://forums.phpfreaks.com/topic/37880-sql-problems/#findComment-181588 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. Link to comment https://forums.phpfreaks.com/topic/37880-sql-problems/#findComment-181593 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.