Jump to content


Photo

more simple question


  • Please log in to reply
3 replies to this topic

#1 zsxdcfv21

zsxdcfv21
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 30 August 2006 - 06:55 AM

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/httpd/vhosts/mywebsitehere/httpdocs/lib.classes/class.MySQL.php on line 132

130 function resultHasRows ()
131 {
132 $numRows = mysql_num_rows( $this->resultResource );
133 if ( $numRows == 0 ) return false;
134 return true;
135 }


what are the possible things why it give out a warning???

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 30 August 2006 - 07:03 AM

There is an error in the query code or the query hasn't been called
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 zsxdcfv21

zsxdcfv21
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 30 August 2006 - 07:07 AM

this is the other script where i could find the resultHasRows() function from the problem above

function trackUser()
{
global $db;
if ( @ isset($_SESSION['EventID']) ) {
// check for session expiry...
$db->setQuery('SELECT EventID FROM SystemUsage WHERE LastPage < DATE_SUB(NOW(), INTERVAL 15 MINUTE) AND EventID = '. (int)$_SESSION['EventID']);
$db->execute();
// expired! bad javascript no workie
if ( $db->resultHasRows() ) {
// set sessionedit
$db->setQuery('UPDATE SystemUsage SET SessionEND = NOW() WHERE EventID = ' . (int)$_SESSION['EventID']);
$db->execute();
// log them out!
session_destroy();
header('Location: index.php?expired=1');
exit();
}
// otherwise hit the last page!
$db->setQuery('UPDATE SystemUsage SET LastPage = NOW() WHERE EventID = ' . (int)$_SESSION['EventID']);
$db->execute();
} else {
// or.. start a new tracking session...
$UserAgent = $_SERVER['HTTP_USER_AGENT'];
$RemoteAddr = $_SERVER['REMOTE_ADDR'];
$db->setQuery('INSERT INTO SystemUsage (UserID, SessionStart, LastPage, UserAgent, RemoteAddr)');
$db->setQuery(" VALUES (" . (int)$_SESSION['UserID'] . ", NOW(), NOW(), '$UserAgent', '$RemoteAddr')");
$db->execute();
$db->setQuery('SELECT LAST_INSERT_ID() EventID');
$row = $db->executeOrDie();
$_SESSION['EventID'] = $row->EventID;
}
}


wc part do you think has a problem? and if ever theres nothing wrong on that part, is there anyway that i could take out the warning message??? coz as soon as i view this link http://mywebsitehere...es&BuyerID=1068, it has a warning message but it display the proper results :

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/httpd/vhosts/mywebsitehere/httpdocs/lib.classes/class.MySQL.php on line 132


#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 30 August 2006 - 06:55 PM

Extra ')' at end

$db->setQuery('SELECT EventID FROM SystemUsage WHERE LastPage < DATE_SUB(NOW(), INTERVAL 15 MINUTE) AND EventID = '. (int)$_SESSION['EventID']);

Also, why the (int) cast when you want to concatenate strings?
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users