zsxdcfv21 Posted August 30, 2006 Share Posted August 30, 2006 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 132130 function resultHasRows () 131 {132 $numRows = mysql_num_rows( $this->resultResource );133 if ( $numRows == 0 ) return false;134 return true; 135 }how can i hide the warning message? can somebody add a small code to supress or hide the error message? Quote Link to comment Share on other sites More sharing options...
Satria Ox41464b Posted August 30, 2006 Share Posted August 30, 2006 $numRows = [b]@[/b]mysql_num_rows( $this->resultResource ); Quote Link to comment Share on other sites More sharing options...
zsxdcfv21 Posted August 30, 2006 Author Share Posted August 30, 2006 million thanks! as soon as i got that right, it all boils down to this problemif ( true == $db->resultHasRows() ) { require_once('func.buyernote.php'); $notes = ''; while ( false != ($r = $db->getObject()) ) { $notes .= makeNote($r->BuyerNoteID, nl2br($r->Note), $r->nCreated, $r->nModified); } } else { $notes = 'No Notes to Display.'; }...it always gave me 'No Notes to Display' ...do u think the warning message has anything to do with this? or is it just theres a problem on this line :while ( false != ($r = $db->getObject()) ) {... please help Quote Link to comment Share on other sites More sharing options...
Satria Ox41464b Posted August 30, 2006 Share Posted August 30, 2006 get pencil and paper...draw your code in there...if (...) <- [b]Your condition is taken here[/b]{ ... [b]and not here[/b]} else { $notes = 'No Notes to Display.';} Quote Link to comment Share on other sites More sharing options...
zsxdcfv21 Posted August 30, 2006 Author Share Posted August 30, 2006 sorry for being such an ignorant to this. im kinda confused on what you were telling me. ive noticed that the lines :if ( true == $db->resultHasRows() ) { ....} else { $notes = 'No Notes to Display.';}are the ones giving me the notes. and again the resutHasRows is involve in there. would that mean that the warning message ago has something to do with this condition if ( true == $db->resultHasRows() ) { thats why i always end up 'No Notes to Display"???? Quote Link to comment Share on other sites More sharing options...
Satria Ox41464b Posted August 30, 2006 Share Posted August 30, 2006 duh... after seeing your code...im not sure which part wrong...mostly because im not familiar with [code](true == $something)[/code] and [code]($something == 0)[/code] a part of thatconsidering that your mysql_num_rows() is 0, thats mean you should return false; (your first post)but why on your next code its always trueum... i guess i found itplease modify [b]Line 133 and 134[/b]130 function resultHasRows ()131 {132 $numRows = mysql_num_rows( $this->resultResource );133 if ( [b]$numRows[/b] ) return [b]true[/b]; 134 return [b]false[/b]; 135 } Quote Link to comment Share on other sites More sharing options...
zsxdcfv21 Posted August 30, 2006 Author Share Posted August 30, 2006 um... i guess i found itplease modify Line 133 and 134130 function resultHasRows ()131 {132 $numRows = mysql_num_rows( $this->resultResource );133 if ( $numRows ) return true; 134 return false; 135 }...so how should i modify that down? sorry for being so much innocent on this. can u modify those 2 lines for me? Quote Link to comment Share on other sites More sharing options...
Satria Ox41464b Posted August 30, 2006 Share Posted August 30, 2006 sob...compare:[quote="zsxdcfv21"]130 function resultHasRows ()131 {132 $numRows = mysql_num_rows( $this->resultResource );133 if ( $numRows == 0 ) return false;134 return true; 135 }[/quote]with[quote="Satria Ox41464b"]130 function resultHasRows ()131 {132 $numRows = mysql_num_rows( $this->resultResource );133 if ( [b]$numRows[/b] ) return [b]true[/b]; 134 return [b]false[/b]; 135 }[/quote] Quote Link to comment Share on other sites More sharing options...
zsxdcfv21 Posted August 30, 2006 Author Share Posted August 30, 2006 hi i did follow the script that u modified :130 function resultHasRows ()131 {132 $numRows = mysql_num_rows( $this->resultResource );133 if ( $numRows ) return true; 134 return false; 135 }unfortunately, nothings change... i guess the problem is with line 132...remember the warning message? what do u think the warning message for? please help...and thanks for the reply Quote Link to comment Share on other sites More sharing options...
zsxdcfv21 Posted August 30, 2006 Author Share Posted August 30, 2006 i tried taking out the @ in this script :130 function resultHasRows ()131 {132 $numRows = @mysql_num_rows( $this->resultResource );133 if ( $numRows ) return true; 134 return false; 135 }but then again the warning message is there again : " 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 "since it mentions about supplied argument, i have to go back to these lines on my other php script :case 'notes': $q = " SELECT n.NoteID, n.Note, date_format(n.Created, '%d %b %y') nCreated, date_format(n.Created, '%d %b %y') nModified FROM BuyerNote n JOIN Buyer b ON b.BuyerID = n.BuyerID AND b.BuyerID = '{$_GET['BuyerID']}' JOIN User u ON b.UserID = u.UserID "; if (!$isAdmin) $q .= " AND u.UserID = '{$_SESSION['UserID']}' "; $q .=" ORDER BY n.Created DESC"; [b]if ( true == $db->resultHasRows() ) {[/b] require_once('func.buyernote.php'); $notes = ''; while ( false != ($r = $db->getObject()) ) { $notes .= makeNote($r->BuyerNoteID, nl2br($r->Note), $r->nCreated, $r->nModified); } } else { $notes = 'No Notes to Display.'; } $o = $db->executeOrDie(" select concat(Firstname, ' ', Surname) Name from Buyer where BuyerID = '{$_GET['BuyerID']}' "); // alterted this 18 august if (!$isSubAdmin) $html->setAction("note_add&BuyerID=".$_GET['BuyerID'], 'Add a Note'); $html->setHeading('View Notes for ' . $o->Name); $html->bindContent($notes); $html->useBackButton($_SERVER['PHP_SELF']); $html->printHTML(); $html->serialise(); $db->execute($q); break;see the bold line " if ( true == $db->resultHasRows() ) { " ...i think thats the part it has problem. but i dont get whats the problem... is there something wrong with my $q above ??? Quote Link to comment Share on other sites More sharing options...
Satria Ox41464b Posted August 30, 2006 Share Posted August 30, 2006 I dont see your code sending Query ($q) to mysql_query() Quote Link to comment Share on other sites More sharing options...
zsxdcfv21 Posted August 30, 2006 Author Share Posted August 30, 2006 could u add it for me please? i dont know where to add that line. Quote Link to comment Share on other sites More sharing options...
zsxdcfv21 Posted August 30, 2006 Author Share Posted August 30, 2006 is it supposed to be$db->setQuery($q);or $db->execute($q);??? Quote Link to comment Share on other sites More sharing options...
Jenk Posted August 30, 2006 Share Posted August 30, 2006 right.. to make it easier, please post the code from the entire class :) Quote Link to comment Share on other sites More sharing options...
webhead Posted September 6, 2006 Share Posted September 6, 2006 Hi, I'm having a similar problem, but the @ symbol does not suppress the messages. Here's my code:[code]$gets = "SELECT * FROM mytable WHERE $criteria"; $result = $connector->query($gets); if (!$rows = $connector->getNumRows($result)) { echo $error; }[/code]Here is the function:[code]function query($query) { $this->theQuery = $query; return @mysql_query($query, $this->link);}[/code]I get the "warning" message if the record being searched for does not exist. Quote Link to comment Share on other sites More sharing options...
webhead Posted September 22, 2006 Share Posted September 22, 2006 Any ideas anyone? 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.