Jump to content


Photo

suppress error message


  • Please log in to reply
15 replies to this topic

#1 zsxdcfv21

zsxdcfv21
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 30 August 2006 - 07:25 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   }

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

#2 Satria Ox41464b

Satria Ox41464b
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 30 August 2006 - 07:28 AM

$numRows = @mysql_num_rows( $this->resultResource );

#3 zsxdcfv21

zsxdcfv21
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 30 August 2006 - 07:35 AM

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


#4 Satria Ox41464b

Satria Ox41464b
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 30 August 2006 - 07:39 AM

get pencil and paper...
draw your code in there...

if (...) <- Your condition is taken here
{
... and not here
} else
{
  $notes = 'No Notes to Display.';
}

#5 zsxdcfv21

zsxdcfv21
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 30 August 2006 - 07:46 AM

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"????

#6 Satria Ox41464b

Satria Ox41464b
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 30 August 2006 - 07:58 AM

duh... after seeing your code...
im not sure which part wrong...
mostly because im not familiar with
(true == $something)
and
($something == 0)


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 Line 133 and 134
130 function resultHasRows ()
131  {
132      $numRows = mysql_num_rows( $this->resultResource );
133      if ( $numRows ) return true;
134      return false;       
135  }

#7 zsxdcfv21

zsxdcfv21
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 30 August 2006 - 08:05 AM

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?

#8 Satria Ox41464b

Satria Ox41464b
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 30 August 2006 - 08:12 AM

sob...
compare:

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


with

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



#9 zsxdcfv21

zsxdcfv21
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 30 August 2006 - 08:33 AM

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

#10 zsxdcfv21

zsxdcfv21
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 30 August 2006 - 08:38 AM

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";





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.';
}


$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 ???

#11 Satria Ox41464b

Satria Ox41464b
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 30 August 2006 - 08:41 AM

I dont see your code sending Query ($q) to mysql_query()



#12 zsxdcfv21

zsxdcfv21
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 30 August 2006 - 08:45 AM

could u add it for me please? i dont know where to add that line.

#13 zsxdcfv21

zsxdcfv21
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 30 August 2006 - 08:49 AM

is it supposed to be

$db->setQuery($q);

or

$db->execute($q);

???

#14 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 30 August 2006 - 08:58 AM

right.. to make it easier, please post the code from the entire class :)

#15 webhead

webhead
  • Members
  • PipPip
  • Member
  • 23 posts
  • LocationOH

Posted 06 September 2006 - 06:16 PM

Hi, I'm having a similar problem, but the @ symbol does not suppress the messages. Here's my code:

$gets = "SELECT * FROM mytable WHERE $criteria";
	$result = $connector->query($gets);
	if (!$rows = $connector->getNumRows($result)) { echo $error; }

Here is the function:
function query($query) {
	$this->theQuery = $query;
	return @mysql_query($query, $this->link);
}

I get the "warning" message if the record being searched for does not exist.

#16 webhead

webhead
  • Members
  • PipPip
  • Member
  • 23 posts
  • LocationOH

Posted 22 September 2006 - 11:32 AM

Any ideas anyone?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users