Warning: mysql_result():

Ok I have the message board I am working on. When you click to see more entires and there are none, this is what appears in the text boxes.

Warning: mysql_result(): Unable to jump to row 6 on MySQL result index 3 in /var/www/html/boylen/GuestBook.php on line 48
Commnets:

This is my PHP loop:

 
if($numallComments == 0) { print "	   No entries yet.."; }
 
else {   
 print "&writename=";	   $name   = mysql_result($fewComments, $i, 'name');	 print'					 '. $name .'';
 print "&writerow=";	   $row   = mysql_result($fewComments, $i, 'name');	 print'					 '. $row .'';
 print "&writelocation=";   $location  = mysql_result($fewComments, $i, 'location'); print'<b>Location: </b><br>'. $location .'';
 print "&writeage=";	$dob   = mysql_result($fewComments, $i, 'dob'); $today = date("Y");  $dob	   = $today - $dob; print'<b>Age: </b>		 '. $dob .'';
 print "&writedate=";	$time   = mysql_result($fewComments, $i, 'time'); $time = date("d-m-Y");  print'<b>Date: </b>		'. $time .'';
 print "&writecomments=";   $comments  = mysql_result($fewComments, $i, 'comments'); print'<b>Commnets: </b><br>'. $comments .'';
for($i=1; $i<=9; $i++){
 print "&writename$i=";	   $name   = mysql_result($fewComments, $i, 'name');	 print'					 '. $name .'';
 print "&writelocation$i=";   $location  = mysql_result($fewComments, $i, 'location'); print'<b>Location: </b><br>'. $location .'';
 print "&writeage$i=";   $dob   = mysql_result($fewComments, $i, 'dob'); $today = date("Y");  $dob	   = $today - $dob; print'<b>Age: </b>		 '. $dob .'';
 print "&writedate$i=";	$time   = mysql_result($fewComments, $i, 'time'); $time = date("d-m-Y");  print'<b>Date: </b>		'. $time .'';
 print "&writecomments$i=";   $comments  = mysql_result($fewComments, $i, 'comments'); print'<b>Commnets: </b><br>'. $comments .'';
}
}

I could search each post for mysql_result(): and if I find it tell it to display “no more entries”
But that wasting time sending error messages to flash and having flash search through each post is going to slow it down.

So I would much prefer to find away to break from the loop when it gets to no more entries.

Anyideas, are there break commands to catch this ?

Um not sure if this is the problem, most likely isn’t but whenever I have a problem where it says can’t jump to row or whatever I realize I forgot to put count in my mysql statement, and since I can’t see how you’re getting the $numAllComments, I can’t tell how you did it. Hope this helps (I never seem to get to help heh).

Hey radio

I will post the mysql statement part, perhaps you can see a error, but I think it is because I have it in that loop that has it return 10 results even when there are no more rows left.

 $DBConn = mysql_connect($DBhost,$DBuser,$DBpass) or die("Error in GuestBook Application: " . mysql_error());
	mysql_select_db($DBName, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
	 $action = $_GET['action'];
   
   switch($action) {
	  case 'read' :
  
   $sql = 'SELECT * FROM `' . $table . '`';  
   $allComments = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
   $numallComments = mysql_num_rows($allComments);
   $sql .= ' ORDER BY `time` DESC LIMIT ' . $_GET['NumLow'] . ', ' . $numComments;
   $fewComments = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
   $numfewComments = mysql_num_rows($fewComments);
  
print '&totalEntries=' . $numallComments . '&';

I tried to do a google search for help…
But that dam error is all over the net so google shows you hundreds of pages that have that error… So i can’t find any tutes or help on it. =(

I couldn’t even find anything in the manual on it…

Oh hm, with the mysq2l_num_rows, I’m not sure about it, cause I am still (even after ayear) fairly new at php and mysql. At first I thought you needed a query such as:

$numallComments = mysql_result(mysql_query("SELECT count(*) FROM " . $table . "),0,0);

and then that is the number of comments you have in the table. I also saw that it has $sql declared a couple times, probably is fine, but I’m not sure. In php it reads down and will replace the variable right? Hmm… you may need someone else on this, I think I’m missing what you need, the point of the thing you’re doing…
as far as I can tell, you are asking for the amount of rows given. Maybe that works like mysql_result and needs a count(*)? try that. other than that, I’m out of ideas.

I need something like this

 
while ($thisrow=mysql_fetch_row($result)) { //get one row at a time
  
 
 
}

So that as soon as it doesn’t get a result it exits the loop.

But I can’t get it to work, it may be the for() loop but with 3 days experience I dont know either.

Thanks trying :slight_smile:

Well I solved that one… now it returns undefined instead of error.

I am hoping I can change that in flash.

hey, sorry I never replied back, I lost my phone/internet this weekend. Glad you uh, solved the problem? This interests me, so I’ll try to remember to look it up tomorrow. I really need to get better php :confused:

I ended up solving both problems…

I just needed to add a condition to the for loop:

else {
		for($i=0; $i<=10 && $array = mysql_fetch_array($fewComments); $i++){
	print "&writename$i=";     	 $name 		= mysql_result($fewComments, $i, 'name');     print''. $name .'';
	print "&writelocation$i="; 	 $location  = mysql_result($fewComments, $i, 'location'); print'<b>Location: </b><br>'. $location .'';
	print "&writeage$i=";		 $dob 		= mysql_result($fewComments, $i, 'dob'); $today = date("Y");  $dob = $today - $dob; print'<b>Age: </b>'. $dob .'';
	print "&writedate$i=";	 	 $time 		= mysql_result($fewComments, $i, 'time'); $time = date("d-m-Y");  print'<b>Date: </b>'. $time .'';
	print "&writecomments$i="; 	 $comments  = mysql_result($fewComments, $i, 'comments'); print'<b>Commnets: </b><br>'. $comments .'';
	}
}

and if I recall correctly the undefined was because I didn’t set my var correct before I called it.
ie:
dog = this.dog
my.text = dog

I had this.cat…
Obvioulsy not dog & cat but you get the idea :slight_smile:

PS:
I pull my hair out when I can’t connect for a few hours, let alone a weekend. :slight_smile:

ah okay cool. And yah I went bald this weekend. I had 15 messeges in gmail. 15! whoa. haha. I guess that’s not that much actually. And it was kinda nice. Like I had friends. Nevermind. haha gnight