Jump to content

Weird Problem


craigory83

Recommended Posts

Okay, so basically my news-like site is supposed to print out article data saved in the database.  It does that quite alright, except on the 3rd article (number 2 in SQL rows or columns.  whichever it is.  I have my counter subtract 1 from the start article to compensate for MySQL)

 

My code:

<?php
print "<div class = 'menu' align='center'>Newest Stories</div>";

if (isset($_REQUEST['mstart']))
{
$start=$_REQUEST['mstart'];
}
else
{
$start=1;
}
if ($start)
{
$start=1;
}

$start--;
$end=$start+5;
$stories = mysql_query("SELECT * FROM stories ORDER BY id DESC LIMIT $start, $end") or die(mysql_error());
$num = mysql_num_rows($stories);
$start++;

if ($num > 0)
{
if ($num<$end)
{
		$end = $end-(5-$num);
}
print "<b><i>Showing stories $start to $end</i></b>";



for ($count=0; $count<$num; $count++)
{
	print "<hr>";	
	$story = mysql_fetch_array($stories,$count);
	$id = $story['id'];
	$headline = $story['headline'];
	$author = $story['author'];
	$desc = $story['description'];
	$content = $story['content'];

			print "COUNT: $count OF $num ($id)<br>";
	print "<a href='index.php?request=story&mstart=$start&story=$id' class='headlinelink'>$headline</a><br>";
	print "<div class='author'>Posted by: <a href='index.php?request=author&mstart=$start&author=$author' class='author'>$author</a>.</div>";
	print "<div class='desc'>$desc</div><br>";
}

}
else
{
print "Error.  No stories found. ";
}

?>

 

Output: (The COUNT x OF y was to help me figure out what is wrong.  In the () by it is the id number of the corresponding MySQL row/column.  I even deleted one of the articles to see if it was a specific article error.  No luck.)

 

Newest Stories

Showing stories 1 to 5

----------------

COUNT: 0 OF 5 (6)

Y U NO STAY

Posted by: craigory83.

GRRR

 

----------------

COUNT: 1 OF 5 (5)

h-l!

Posted by: craigory83.

desc

 

----------------

Notice: Undefined index: id in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\dba\menu.php on line 37

 

Notice: Undefined index: headline in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\dba\menu.php on line 38

 

Notice: Undefined index: author in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\dba\menu.php on line 39

 

Notice: Undefined index: description in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\dba\menu.php on line 40

 

Notice: Undefined index: content in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\dba\menu.php on line 41

COUNT: 2 OF 5 ()

 

Posted by: .

 

----------------

COUNT: 3 OF 5 (2)

This is the second story!

Posted by: TDWP83.

See, I fuckin told you so!

 

 

Warning: mysql_fetch_array() [function.mysql-fetch-array]: The result type should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\dba\menu.php on line 36

 

----------------

COUNT: 4 OF 5 (1)

This is the mother fucking headline!

Posted by: craigory83.

stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.