abch624 Posted July 14, 2008 Share Posted July 14, 2008 Hi Guys I have this sql statement that I execute, $sql_check_language="SELECT isoID FROM $tbl_languagetemplate WHERE isoID='$newlangaugeID'"; $result_check_language=mysql_query($sql_check_language); $count=mysql_num_rows($result_check_language); When I reach this code I get this error: "Query was empty" I have 0 rows for this query in the database. I expect 0 to be returned.... Any help guys or any ways to catch this? Cheers - Zahid Link to comment https://forums.phpfreaks.com/topic/114650-mysql_num_rows-error/ Share on other sites More sharing options...
vikramjeet.singla Posted July 14, 2008 Share Posted July 14, 2008 will please provide output for $sql_check_language variable... Link to comment https://forums.phpfreaks.com/topic/114650-mysql_num_rows-error/#findComment-589529 Share on other sites More sharing options...
abch624 Posted July 14, 2008 Author Share Posted July 14, 2008 I did an echo on the $sql_check_language variable I get this: SELECT isoID FROM languagetemplate WHERE isoID='uykgfyk' Query was empty cheers - zahid Link to comment https://forums.phpfreaks.com/topic/114650-mysql_num_rows-error/#findComment-589530 Share on other sites More sharing options...
themistral Posted July 14, 2008 Share Posted July 14, 2008 So do you want to check to see if the query is empty? In that case try if (mysql_num_rows($result_check_language) > 0) { // run the code if 1 or more results } else { // error message or whatever here } Hope that's what you were getting at!! Link to comment https://forums.phpfreaks.com/topic/114650-mysql_num_rows-error/#findComment-589545 Share on other sites More sharing options...
Xurion Posted July 14, 2008 Share Posted July 14, 2008 If you're simply counting rows (and not using the data) you should write an SQL statement that uses the COUNT method. SELECT COUNT(*) FROM table; And reference it with: $row['COUNT']; Link to comment https://forums.phpfreaks.com/topic/114650-mysql_num_rows-error/#findComment-589547 Share on other sites More sharing options...
vikramjeet.singla Posted July 14, 2008 Share Posted July 14, 2008 can you execute this code and let me know the output: $sql_check_language="SELECT isoID FROM $tbl_languagetemplate WHERE isoID='$newlangaugeID'"; $result_check_language = mysql_query($sql_check_language) or die(mysql_error()); and want to make sure have you created the connection.... Link to comment https://forums.phpfreaks.com/topic/114650-mysql_num_rows-error/#findComment-589552 Share on other sites More sharing options...
MasterACE14 Posted July 14, 2008 Share Posted July 14, 2008 I believe the problem is not in the query or PHP itself. But in a typo. take a closer look: $sql_check_language="SELECT isoID FROM $tbl_languagetemplate WHERE isoID='$newlangaugeID'"; WHERE isoID='$newlangaugeID'"; '$newlangaugeID' langauge there's your problem above. Regards ACE Link to comment https://forums.phpfreaks.com/topic/114650-mysql_num_rows-error/#findComment-589563 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.