MySQL Forums
Forum List  »  PHP

Re: mysql_num_rows(): supplied argument is not a valid MySQL result
Posted by: Peter Brawley
Date: May 21, 2012 02:33PM

Change the func to something like ...

function runQuery($query) {
  $connect = mysql_connect(MYSQL_SERVER, MYSQL_USERNAME, MYSQL_PASSWORD)
             or exit( "<div class=\"error\">" . mysql_error() . "</div>" );
  mysql_select_db(MYSQL_DATABASE, $connect)
    or exit( "<div class=\"error\">" . mysql_error() . "</div>" );
  $result = mysql_query($query, $connect);
            or exit( "<div class=\"error\">" . mysql_error() . "</div>" );
  return $result;
}

And once you have that working, consider improving it by changing the exit() calls to invoke an error handling function that logs errors to an error file.

PB

Options: ReplyQuote


Subject
Written By
Posted
Re: mysql_num_rows(): supplied argument is not a valid MySQL result
May 21, 2012 02:33PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.