[SOLVED] Help Needed on mysgl_fetch_array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Fusion
Forum Newbie
Posts: 13
Joined: Wed May 12, 2004 9:48 am

[SOLVED] Help Needed on mysgl_fetch_array

Post by Fusion »

Hello.

So i needed to switch hosts, so I did. Upon upload of the files to the new site, only one PHP script does not work. I must have all db connect info right, db name and everything, but when i view the page I get the following:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/httpd/vhosts/omninite.com/subdomains/lw/httpdocs/site/index.php on line 538

here is my script, whats up? I did not change anything, just dled from old host and uploaded to new host. P.S. mysql_connect info taken out for secuity reasons :-)

P.S.S. Line # 538 is

Code: Select all

while ($row = mysql_fetch_array($top_poster_sql))

Code: Select all

<?php
mysql_connect("localhost", "computer_LWForum", "DFF20466") or
  die("Could not connect: " . mysql_error());
  
$db_name = "computer_LWForum";  // The name of the database where your forums are installed
  
mysql_select_db($db_name);

// Variables
$ibf_members = "ibf_members";  // The name of your members table
$ibf_member_extra = "ibf_member_extra";
$ibf_groups = "ibf_groups";

$top_poster_sql = mysql_query("SELECT name, posts
         FROM $ibf_members m 
         LEFT JOIN $ibf_member_extra me ON me.id=m.id 
         LEFT JOIN $ibf_groups g ON m.mgroup=g.g_id 
         WHERE m.id > 0 AND g.g_hide_from_list <> 1 
         ORDER BY posts desc LIMIT 0, 5");


echo "<table cellpadding='4' cellspacing='1' border='0' width='100%' height="145" style="color: #093349; font-family: Verdana, Tahoma, Arial, sans-serif; font-size: 10px" id="table52">";
echo "<tr style="color: #093349; font-family: Verdana, Tahoma, Arial, sans-serif; font-size: 10px">";
echo "<td colspan='2' class='maintitle' background='tile_sub.gif' height="12">";
echo "<p align="left"><b>.::Top Five PosterZ::.</b></td>";
echo "</tr>";
echo "<tr style="color: #093349; font-family: Verdana, Tahoma, Arial, sans-serif; font-size: 10px">";
echo "<td class='row1' valign='middle' align='left' width='35%' height="10"><b>Username</b></td>";
echo "<td class='row1' valign='middle' align='left' width='65%' height="10">";
echo "<p align="center">";
echo "<b>Posts</b></td>";
echo "</tr>";



			   
echo "<tbody>";
while ($row = mysql_fetch_array($top_poster_sql))
{

$NAME   =  $row["name"];
$POSTS   =  $row["posts"];
echo "<tr style="color: #093349; font-family: Verdana, Tahoma, Arial, sans-serif; font-size: 10px">";
echo "<td class='row4' width='80%' height="12" align="left">$NAME</td>";
echo "<td class='row4' width='20%' align='right' height="12">$POSTS</td>";
echo "</tr>";
}
echo "</table>";
echo "</td>";
echo "</tr>";


echo "</table>";
?>
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

change

Code: Select all

$top_poster_sql = mysql_query("SELECT name, posts 
         FROM $ibf_members m 
         LEFT JOIN $ibf_member_extra me ON me.id=m.id 
         LEFT JOIN $ibf_groups g ON m.mgroup=g.g_id 
         WHERE m.id > 0 AND g.g_hide_from_list <> 1 
         ORDER BY posts desc LIMIT 0, 5");
to

Code: Select all

$top_poster_sql = mysql_query("SELECT name, posts 
         FROM $ibf_members m 
         LEFT JOIN $ibf_member_extra me ON me.id=m.id 
         LEFT JOIN $ibf_groups g ON m.mgroup=g.g_id 
         WHERE m.id > 0 AND g.g_hide_from_list <> 1 
         ORDER BY posts desc LIMIT 0, 5") or die (mysql_error());
..and see what happens now

Mark
Fusion
Forum Newbie
Posts: 13
Joined: Wed May 12, 2004 9:48 am

Post by Fusion »

the error i get is No Database Selected. yet there is...

Code: Select all

mysql_select_db($db_name);
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Code: Select all

mysql_select_db($db_name) or die(mysql_error());
Fusion
Forum Newbie
Posts: 13
Joined: Wed May 12, 2004 9:48 am

Post by Fusion »

ok wrong username or host. thanks fo the help
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Fusion wrote:ok wrong username or host. thanks fo the help
Haha...DOH!! :lol:

usually turns out to be simple. I had a right headache with a problem yesterday, turned out to be something even a newbie would know :)

Mark
Post Reply