Jump to content

Archived

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

zsxdcfv21

suppress error message

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   }

how can i hide the warning message? can somebody add a small code to supress or hide the error message?

Share this post


Link to post
Share on other sites
million thanks! as soon as i got that right, it all boils down to this problem

if ( 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

Share this post


Link to post
Share on other sites
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.';
}

Share this post


Link to post
Share on other sites
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"????

Share this post


Link to post
Share on other sites
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 that
considering that your mysql_num_rows() is 0,
thats mean you should return false; (your first post)

but why on your next code its always true


um... i guess i found it
please 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  }

Share this post


Link to post
Share on other sites
um... i guess i found it
please modify Line 133 and 134
130 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?

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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&amp;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 ???

Share this post


Link to post
Share on other sites
right.. to make it easier, please post the code from the entire class :)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

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.