SQL error problem

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
jwmelton
Forum Newbie
Posts: 2
Joined: Mon Mar 20, 2006 9:32 am

SQL error problem

Post by jwmelton »

Hey guys,

I've got a SQL error I haven't encountered before and I was looking for some help:

Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 22 in /site/page.php on line 697
Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 25 in /site/page.php on line 696

I'll warn you, I'm still fairly new to SQL so keep it simple.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

post your code.
jwmelton
Forum Newbie
Posts: 2
Joined: Mon Mar 20, 2006 9:32 am

Post by jwmelton »

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Heh, thought I had included. Here it is: 

Just so you know, it isn't my code... I'm just working on fixing it until I have time to write my own.

Code: Select all

<?
		$ed = mysql_query("select * from Blogs where category='Business' order by blogId desc");
		$i=0;
		while($i<5 && ($i<mysql_num_rows($ed))){
			$title = mysql_result($ed, $i, "title");
			$blogId = mysql_result($ed, $i, "blogId");
			echo "<a href='http://www1.romenews-tribune.com/module/blogs/blog.php?id=$blogId' style='color:darkblue'>$title</a>";
			$i++;
			if($i<5 && ($i<mysql_num_rows($ed))){
				echo "<br>";
			}// end of if
		}// end of while
		if(mysql_num_rows($ed)>5){
			echo "<br><br><a href='http://www1.romenews-tribune.com/module/blogs/category.php?cat=Business' style='color:darkblue'>View full list...</a>";
		}// end of if		
?>

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

<?php

$ed = mysql_query("SELECT `title`, `blogId` FROM `Blogs` WHERE `category` = 'Business' ORDER BY `blogId` DESC LIMIT 6");
$stuff = array();
$c = 0;
while($row = mysql_fetch_assoc($ed))
{
  $stuff[] = '<a href="http://www1.romenews-tribune.com/module/blogs/blog.php?id=' . $blogId . '" style="color:darkblue">' . $title . '</a>';
  $c++;
  if($c == 5)
  {
    break;
  }
}
echo implode('<br>', $stuff);

if(mysql_num_rows($ed) > 5)
{
  echo '<br><br><a href="http://www1.romenews-tribune.com/module/blogs/category.php?cat=Business" style="color:darkblue">View full list...</a>';
}

?>
Post Reply