Jump to content

more simple question


zsxdcfv21

Recommended Posts

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???
Link to comment
https://forums.phpfreaks.com/topic/19107-more-simple-question/
Share on other sites

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/app/buyer.php?action=notes&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
Link to comment
https://forums.phpfreaks.com/topic/19107-more-simple-question/#findComment-82650
Share on other sites

Extra ')' at end

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

Also, why the (int) cast when you want to concatenate strings?
Link to comment
https://forums.phpfreaks.com/topic/19107-more-simple-question/#findComment-83063
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.