# Warning: mysql\_result():

**URL:** <https://forum.kirupa.com/t/warning-mysql-result/58489>\
**Category:** Uncategorized\
**Created:** [July 22, 2004, 9:39pm UTC](https://forum.kirupa.com/t/warning-mysql-result/58489 "2004-07-22T21:39:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![The\_Vulcan](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/the_vulcan/32/145_2.png) [@The\_Vulcan](https://forum.kirupa.com/u/The_Vulcan)\
**Post date:** [July 22, 2004, 9:39pm UTC](https://forum.kirupa.com/t/warning-mysql-result/58489/1 "2004-07-22T21:39:32Z")

</div>

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:

```php
 
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 ?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 22, 2004, 10:59pm UTC](https://forum.kirupa.com/t/warning-mysql-result/58489/2 "2004-07-22T22:59:23Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 22, 2004, 11:05pm UTC](https://forum.kirupa.com/t/warning-mysql-result/58489/3 "2004-07-22T23:05:18Z")

</div>

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.

```auto
 $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…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 22, 2004, 11:22pm UTC](https://forum.kirupa.com/t/warning-mysql-result/58489/4 "2004-07-22T23:22:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 22, 2004, 11:29pm UTC](https://forum.kirupa.com/t/warning-mysql-result/58489/5 "2004-07-22T23:29:00Z")

</div>

I need something like this

```php
 
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 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 23, 2004, 2:27am UTC](https://forum.kirupa.com/t/warning-mysql-result/58489/6 "2004-07-23T02:27:37Z")

</div>

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

I am hoping I can change that in flash.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 27, 2004, 8:04am UTC](https://forum.kirupa.com/t/warning-mysql-result/58489/7 "2004-07-27T08:04:55Z")

</div>

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 😕

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 27, 2004, 8:24am UTC](https://forum.kirupa.com/t/warning-mysql-result/58489/8 "2004-07-27T08:24:32Z")

</div>

I ended up solving both problems…

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

```php
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 🙂

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 27, 2004, 8:36am UTC](https://forum.kirupa.com/t/warning-mysql-result/58489/9 "2004-07-27T08:36:30Z")

</div>

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
