Jump to content


Photo

mysql_selectdb() vs. mysql_select_db()


  • Please log in to reply
5 replies to this topic

#1 vethost

vethost
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 03 June 2006 - 04:54 PM

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 16

The 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

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 03 June 2006 - 06:06 PM

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.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 vethost

vethost
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 03 June 2006 - 06:17 PM

[!--quoteo(post=379676:date=Jun 3 2006, 02:06 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Jun 3 2006, 02:06 PM) View Post[/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!


#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 03 June 2006 - 10:41 PM

After the mysql_query() call.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#5 vethost

vethost
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 04 June 2006 - 02:35 PM

[!--quoteo(post=379754:date=Jun 3 2006, 06:41 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Jun 3 2006, 06:41 PM) View Post[/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"

#6 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 04 June 2006 - 05:02 PM

[!--quoteo(post=379889:date=Jun 4 2006, 10:35 AM:name=Vethost)--][div class=\'quotetop\']QUOTE(Vethost @ Jun 4 2006, 10:35 AM) View Post[/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.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users