db530 Posted June 5, 2008 Share Posted June 5, 2008 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /data/16/1/57/83/1546246/user/1664829/htdocs/sub_category.php on line 118 Here is an example page: http://www.industrialpc.com/sub_category.php?cat_id=161 I take it there is something wrong with my MySQL db, any suggestions? Link to comment https://forums.phpfreaks.com/topic/108894-solved-does-this-error-mean-there-is-something-wrong-with-my-database/ Share on other sites More sharing options...
Barand Posted June 5, 2008 Share Posted June 5, 2008 It means there is an error in your query. Get the contents of mysql_error() to see what's wrong Link to comment https://forums.phpfreaks.com/topic/108894-solved-does-this-error-mean-there-is-something-wrong-with-my-database/#findComment-558709 Share on other sites More sharing options...
db530 Posted June 6, 2008 Author Share Posted June 6, 2008 Thanks. When I check for the error I get "No database selected", I have to use the IP as the host. It's right along with the username, password, and database. Any ideas? Link to comment https://forums.phpfreaks.com/topic/108894-solved-does-this-error-mean-there-is-something-wrong-with-my-database/#findComment-559314 Share on other sites More sharing options...
fenway Posted June 6, 2008 Share Posted June 6, 2008 Sounds like you're missing a call to mysql_select_db.... impossible to tell since we haven't seen any code. Link to comment https://forums.phpfreaks.com/topic/108894-solved-does-this-error-mean-there-is-something-wrong-with-my-database/#findComment-559356 Share on other sites More sharing options...
db530 Posted June 6, 2008 Author Share Posted June 6, 2008 Here is my connect function, it calls mysql_select_db....Is there any other code I should post? function dbcon(){ global $host, $user, $pass, $db,$link; if(!($link=mysql_connect($host,$user,$pass))) { sprintf("Internal error %d %s",mysql_errno(),mysql_error()); return 0; } else { return 1; mysql_select_db($db); } Link to comment https://forums.phpfreaks.com/topic/108894-solved-does-this-error-mean-there-is-something-wrong-with-my-database/#findComment-559364 Share on other sites More sharing options...
Barand Posted June 6, 2008 Share Posted June 6, 2008 it calls mysql_select_db.... No it doesn't. It returns before the call Link to comment https://forums.phpfreaks.com/topic/108894-solved-does-this-error-mean-there-is-something-wrong-with-my-database/#findComment-559367 Share on other sites More sharing options...
db530 Posted June 6, 2008 Author Share Posted June 6, 2008 Can you please tell me where it would go then? I'm new to this. Link to comment https://forums.phpfreaks.com/topic/108894-solved-does-this-error-mean-there-is-something-wrong-with-my-database/#findComment-559369 Share on other sites More sharing options...
Barand Posted June 6, 2008 Share Posted June 6, 2008 As soon as you use "return $val" you exit the function. try else { mysql_select_db($db); return 1; } Link to comment https://forums.phpfreaks.com/topic/108894-solved-does-this-error-mean-there-is-something-wrong-with-my-database/#findComment-559370 Share on other sites More sharing options...
db530 Posted June 6, 2008 Author Share Posted June 6, 2008 Thank you barand! It worked! Link to comment https://forums.phpfreaks.com/topic/108894-solved-does-this-error-mean-there-is-something-wrong-with-my-database/#findComment-559377 Share on other sites More sharing options...
fenway Posted June 7, 2008 Share Posted June 7, 2008 Thank you barand! It worked! Oh sure, Barand gets the credit ;-) lol.... j/k...glad you got it working. Link to comment https://forums.phpfreaks.com/topic/108894-solved-does-this-error-mean-there-is-something-wrong-with-my-database/#findComment-560019 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.