-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);
5
  • PHP version into your server ???
    – d.danailov
    Commented Jul 16, 2013 at 15:17
  • 2
    As per the usual for your error message: Your query has failed somehow, your code blindly assumes success, and blundered onwards.
    – Marc B
    Commented Jul 16, 2013 at 15:22
  • @MikeyT - have you tried $result = mysql_query($query,$link) or die (mysql_error()); ? Or var_dump($result?
    – andrewsi
    Commented Jul 16, 2013 at 15:27
  • Yes ive tried that, in my error log it says exactly the same error which is displayed on screen
    – MikeyT
    Commented Jul 16, 2013 at 15:29
  • @MikeyT - and what does var_dump($result) show?
    – andrewsi
    Commented Jul 16, 2013 at 15:38

3 Answers 3

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);
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();
-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);
1
  • I get the same error again unfortunately
    – MikeyT
    Commented Jul 16, 2013 at 15:36

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.