zsxdcfv21 Posted August 30, 2006 Share Posted August 30, 2006 got a warning message on line 132. line 132 is in bold lettersWarning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/httpd/vhosts/mywebsitehere.com/httpdocs/lib.classes/class.MySQL.php on line 132<?phpclass MySQL { var $hostname, $username, $password, $dbName, $dbCn, $sqlQuery, $resultResource; function MySQL( $hostname = 'xxxxx', $username = xxxxx, $password = xxxxx, $dbName = xxxxx) { /*** * this class will check for constants that it requires.. if params were not supplied? */ // init variables $this->hostname = $hostname; $this->username = $username; $this->password = $password; $this->dbName = $dbName; $this->sqlQuery = ''; $this->resultResource = NULL; // connect to db $this->dbCn = mysql_connect($this->hostname, $this->username, $this->password) or $this->error(); // select db mysql_select_db($this->dbName, $this->dbCn) or $this->error(); } function error () { if ( ! class_exists('NiceMail') ) require('class.NiceMail.php'); $mail = new NiceMail('xxxxxxx', 'xxxxxx@xxxxx.com'); $mail->setSubject('Error in ' . $_SERVER["SCRIPT_NAME"] ); $mail->setRecipient('MySQL', 'xxxxxx@xxxxx.com'); $error = "[MySQL Error!!!]\nErrorNo:"; $error .= mysql_errno() . "\nError:" . mysql_error() . "\n"; $this->password = 'Intentionally removed.'; ob_start(); var_dump( $this ); $error .= ob_get_contents(); ob_end_clean(); $mail->setBody($error); $mail->sendMail(); require('func.error.php'); sendAlert('Globals Dump for MySQL wrapper.'); exit(); } function setQuery ( $queryString ) { // appends to query! $this->sqlQuery .= $queryString; } function execute ( $queryString = NULL ) { // execute the query if ($queryString !== NULL) { $this->setQuery($queryString); } $this->resultResource = mysql_query( $this->sqlQuery ) or $this->error(); // query was successful if this far, reset query $this->sqlQuery = ''; } function executeOrDie ( $queryString = NULL ) { // if no rows return... terminate if ($queryString !== NULL) { $this->setQuery($queryString); } $this->execute(); if ( ! $this->resultHasRows() ) { require('func.error.php'); sendAlert('Execute or Die Died!'); exit(); } return mysql_fetch_object($this->resultResource); } function executeQuietly ( $queryString = NULL ) { // execute the query but don't bounce an error if ($queryString !== NULL) { $this->setQuery($queryString); } $this->resultResource = mysql_query( $this->sqlQuery ); $this->sqlQuery = ''; } function executeQuickly ( $queryString ) { // executes a single string (and appends old sql query) and returns an object..! $this->setQuery( $queryString ); $this->execute(); return $this->getObject(); } function isError () { if ( $this->resultResource === FALSE ) { return TRUE; } else { return FALSE; } } function getErrorNum () { return mysql_errno( $this->dbCn ); } function resultHasRows () { [b]$numRows = mysql_num_rows( $this->resultResource );[/b] if ($numRows) return true; return false; } function getObject () { // fetch a mysql object if any left if ( $object = mysql_fetch_object($this->resultResource) ) { // return the object return $object; } else { // return false and free resource mysql_free_result( $this->resultResource ); return false; } } function getLastInsertId () { $obj = $this->executeQuickly('SELECT LAST_INSERT_ID() LastInsertID'); return (int) $obj->LastInsertID; } function getNumRows () { return mysql_num_rows( $this->resultResource ); } }?>whats wrong with my script? is it because of resultResource? Quote Link to comment Share on other sites More sharing options...
trq Posted August 30, 2006 Share Posted August 30, 2006 More than likely your query is failing... you should try some debugging to locate the actual cause. Quote Link to comment Share on other sites More sharing options...
zsxdcfv21 Posted August 30, 2006 Author Share Posted August 30, 2006 thats the problem.... theres no errors except warning messages....can you pinpoint to me wc do you think is the problem? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.