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? Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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); } Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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; } Quote Link to comment Share on other sites More sharing options...
db530 Posted June 6, 2008 Author Share Posted June 6, 2008 Thank you barand! It worked! Quote Link to comment 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. 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.