vethost Posted June 3, 2006 Share Posted June 3, 2006 I read in the PHP site, "For downward compatibility mysql_selectdb() can also be used. This is deprecated however."I'm trying to install a third-party script, but keep getting this error:Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/user/www/base_top_v.php on line 16The code snippet including Line 16 in base_top_v.php reads:<? $accounts = mysql_query("select * from banners where id >= '1' order by name asc"); $total_found=mysql_num_rows($accounts); srand(date("s")); $number = rand() % $total_found; if ($number == "0") { $number = 1; } while ($get_rows=@mysql_fetch_array($accounts)) { $ccc = $ccc + 1; if ($ccc == "$number") { $banner_url=$get_rows[banner_url]; $link_url=$get_rows[link_url]; } } ?> I've narrowed it down I think to the use of mysql_select_db() in the script. I am not running the latest version of Mysql, so I was wondering if I should seek out all the occurences of that term and replace it with mysql_selectdb()Any thoughts? I'm running mysql 4.0x Quote Link to comment https://forums.phpfreaks.com/topic/11094-mysql_selectdb-vs-mysql_select_db/ Share on other sites More sharing options...
fenway Posted June 3, 2006 Share Posted June 3, 2006 I don't think that's the problem -- if your query is failing for some reason, you'd get the same error. Try adding "or die mysql_error()" and see what you get. Quote Link to comment https://forums.phpfreaks.com/topic/11094-mysql_selectdb-vs-mysql_select_db/#findComment-41506 Share on other sites More sharing options...
vethost Posted June 3, 2006 Author Share Posted June 3, 2006 [!--quoteo(post=379676:date=Jun 3 2006, 02:06 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Jun 3 2006, 02:06 PM) [snapback]379676[/snapback][/div][div class=\'quotemain\'][!--quotec--]I don't think that's the problem -- if your query is failing for some reason, you'd get the same error. Try adding "or die mysql_error()" and see what you get.[/quote]I am a noob. Where exactly do I put that snippet?Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/11094-mysql_selectdb-vs-mysql_select_db/#findComment-41509 Share on other sites More sharing options...
fenway Posted June 3, 2006 Share Posted June 3, 2006 After the mysql_query() call. Quote Link to comment https://forums.phpfreaks.com/topic/11094-mysql_selectdb-vs-mysql_select_db/#findComment-41582 Share on other sites More sharing options...
vethost Posted June 4, 2006 Author Share Posted June 4, 2006 [!--quoteo(post=379754:date=Jun 3 2006, 06:41 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Jun 3 2006, 06:41 PM) [snapback]379754[/snapback][/div][div class=\'quotemain\'][!--quotec--]After the mysql_query() call.[/quote]Thanks. I tried adding it several times in different ways and get "Parse error: parse error, unexpected T_STRING" Quote Link to comment https://forums.phpfreaks.com/topic/11094-mysql_selectdb-vs-mysql_select_db/#findComment-41717 Share on other sites More sharing options...
fenway Posted June 4, 2006 Share Posted June 4, 2006 [!--quoteo(post=379889:date=Jun 4 2006, 10:35 AM:name=Vethost)--][div class=\'quotetop\']QUOTE(Vethost @ Jun 4 2006, 10:35 AM) [snapback]379889[/snapback][/div][div class=\'quotemain\'][!--quotec--]Thanks. I tried adding it several times in different ways and get "Parse error: parse error, unexpected T_STRING"[/quote]Does that mean you didn't get it do work? See [a href=\"http://ca.php.net/mysql_error\" target=\"_blank\"]here[/a] if you're still having trouble. Quote Link to comment https://forums.phpfreaks.com/topic/11094-mysql_selectdb-vs-mysql_select_db/#findComment-41783 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.