That sort of error usually indicates that the query had a SQL syntax error which prevented it from running, so the mysql_query() call returned a boolean false instead of a query result resource. Or your database connection may have failed, which then caused mysql_query() to fail.

Adding the following to the start of the script may help you locate the source of the problem:

<?php
ini_set('display_errors', 1); // set to 0 for production version
error_reporting(E_ALL);
// rest of script.....
?>

    Replace $result with whatever variable you use as paramter in the function call on 137 and
    preceed that line with

    if ($result === false)
    	error_log(mysql_errno . ': ' .mysql_error());

      nothing comes up. isnt there an alternative to mysql_num_rows? how would i edit the script?

        It's not an issue of mysql_num_rows() not working, it's an issue of the mysql_query() which preceded it not working, and the resulting return value then being used as the parameter to mysql_num_rows(). So you need to find out why it (the mysql_query() call) is returning false instead of a valid resource. Try johanafm's code, but change the error_log(mysql_error()) to die(mysql_error()) (and make sure display_errors is turned on as I indicated above).

          As for your concern with mysql_num_rows, that function is not your problem. As NogDog wrote in his first post, the problem is that you call it like this

          // the result of the query is false, not a result set resource
          $result = mysql_query($some_query);
          // which means the above is the exact same thing as
          $result = false;
          
          // and since the above is false...
          mysql_num_rows($result);
          // the above line is the same as
          mysql_num_rows(false);
          
            johanafm;10930600 wrote:

            Replace $result with whatever variable you use as paramter in the function call on 137 and
            preceed that line with

            if ($result === false)
            	error_log(mysql_errno . ': ' .mysql_error());

            just to make sure i'm not doing it wrong can you explain more on this?

              First off, there's an error there. It's supposed to be mysql_errno() since it's a function call. Both functions uses the latest created db link unless a link is explicitly specified like this

              $link = mysql_connect( /* ... */);
              $result = mysql_query("Will not work");
              echo mysql_errno($link);

              mysql_errno() shows an error number and mysql_error() shows an error message.

              $result = mysql_query("Something that goes wrong");
              
              /* $result is now false, so it can't be used with functions that take a result set resource, such as
                  mysql_num_rows or mysql_fetch_assoc
                  If it is indeed a result set resource, then the if check below evaluates to false and is bypassed
              */
              if (!$result) {
              // my suggestion, which invokes the current error_handler (may display, mail, write to file)
              	error_log(mysql_errno() . ': ' . mysql_error());
              // or NogDog's suggestion, which write to standard output and terminates the script
              	die(mysql_errno() . ': ' . mysql_error());
              }
              
              /* With my approach, you'd somehow need to deal with not proceeding to use $result with
                  mysql functions, since they will fail. e.g */
              else {
              	// mysql_functions here
              }

              You should follow a similar approach when conneting to the db as well

              $link = mysql_connect( /* ... */);
              if (!$link) {
              	// decide what to do...
              }
              
                Write a Reply...