-3

After uploading the site to my web server I get this message:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource 
in /home1/m1k3ey/public_html/MikeyDev.com/teamdesire/playersheet.php on line 8

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource 
in /home1/m1k3ey/public_html/MikeyDev.com/teamdesire/playersheet.php on line 9

My PHP version is:

PHP Version 5.2.17

I cant see where im going wrong in my code, can anyone please assist:

          mysql_select_db('teamdesire', $link);
          $query = "SELECT * FROM playershowercase";
          $result = mysql_query($query,$link);
          $row = array();
Line 8 >  while($row[] = mysql_fetch_array($result));
Line 9 >  $count = mysql_num_rows($result);
          $random = rand(0,$count-1);
djf
  • 6,592
  • 6
  • 44
  • 62
MikeyT
  • 1
  • 2
  • 2
  • 4

3 Answers3

0

Maybe something like the following?

      mysql_select_db('teamdesire', $link);
      $query = "SELECT * FROM playershowercase";
      $result = mysql_query($query,$link);
      $row = mysql_fetch_assoc($result);
      $count = mysql_num_rows($result);
      $random = rand(0,$count-1);

Or

      mysql_select_db('teamdesire', $link);
      $query = "SELECT * FROM playershowercase";
      $result = mysql_query($query,$link);
      while ($row = mysql_fetch_array($result, MYSQL_NUM))
      $count = mysql_num_rows($result);
      $random = rand(0,$count-1);
Malcolm
  • 784
  • 3
  • 7
  • 20
0

Possible error sources:

  • Db is not running on specified socket or port.
  • Insufficient permissions on the table or database.
  • Incorrect login credentials.
  • Table does not exist or is misspelled.

Echo line per line when you troubleshoot.

is_resource($link) or die('Could not connect');
mysql_query(...);
echo mysql_error();
Gustav
  • 2,902
  • 1
  • 25
  • 31
-1

Try this:

          mysql_select_db('teamdesire', $link);
          $query = "SELECT * FROM playershowercase";
          $result = mysql_query($query,$link);
          $row = array();
          while($result = mysql_fetch_array($result))
          {
          $row[]=$result;
          }
          $count = mysql_num_rows($result);
          $random = rand(0,$count-1);
131
  • 1,363
  • 1
  • 12
  • 32