Page 2 of 2

Posted: Thu Dec 06, 2007 3:34 pm
by SBukoski
If you want to show all the listings you have to iterate through your result set. So something like this should do the trick.

Code: Select all

     else
     {
          while ($row = mysql_fetch_assoc($display))
          {
               $output. = $row['date'] . $row['task'] . $row['points'] . $row['notes'] . '<br />';
               print($output);
          }
     }
Just paste that in place of the old code.

Posted: Thu Dec 06, 2007 3:50 pm
by 4Boredom
bah... i do that and the page goes blank again

Posted: Thu Dec 06, 2007 4:02 pm
by John Cartwright
4Boredom wrote:bah... i do that and the page goes blank again
Because there is a parse somewhere.

Posted: Thu Dec 06, 2007 5:39 pm
by SBukoski
And what I put is slightly incorrect. The print should be outside the loop, otherwise you'll see a lot of the same things listed over and over.

Code: Select all

     else
     {
          while ($row = mysql_fetch_assoc($display))
          {
               $output. = $row['date'] . $row['task'] . $row['points'] . $row['notes'] . '<br />';
          }
          print($output);
     }

Posted: Fri Dec 07, 2007 11:23 am
by 4Boredom
Ok ive broken down the code taking stuff out with comments, and something between line 3 and after is what is killing the code and making the page go blank..

yet i see no errors, and reports arent doing anything... and when i edited my php.ini it messed stuff up

anyone see an error here?

Code: Select all

$display= mysql_query("SELECT * FROM `points` WHERE `username`= '" . $username . "'"); 
$output = '';  

if (!$display) 
{ 
print("A database error has occurred. Please contact your administrator"); 
} 
else  
{
$row = mysql_fetch_array($display);
if(!empty($row['tasknum']))
{
echo 'You have no tasks recorded on record.';
}

Posted: Fri Dec 07, 2007 11:31 am
by John Cartwright
Start indenting your code, you might notice something you didn't before.

Posted: Fri Dec 07, 2007 11:49 am
by 4Boredom
I had it indented and just switched it that way again.. i simply CANT find the error... ive changed the ' to " and vice versa on echos and prints... nothing happening.. white page... and when I comment up until this section it works so it must be here

Code: Select all

if(!$display) 
	{ 
		print('A database error has occurred. Please contact your administrator'); 
	} 
else  
	{
		$row = mysql_fetch_array($display);
		if(!empty($row['tasknum']))
	{
		echo "You have no tasks recorded on record.";
	}}
the whole code is

Code: Select all

$display= mysql_query("SELECT * FROM `points` WHERE `username`= '" . $username . "'"); 
$output = '';  

if(!$display) 
	{ 
		print('A database error has occurred. Please contact your administrator'); 
	} 
else  
	{
		$row = mysql_fetch_array($display);
		if(!empty($row['tasknum']))
	{
		echo "You have no tasks recorded on record.";
	} }


if(!mysql_num_rows($display)) 
     { 
          print('You have no tasks recorded on record.'); 
     } 
else 
     { 
				 while ($row = mysql_fetch_assoc($display)) 
          { 
				  $output. = $row['date'] . $row['task'] . $row['points'] . $row['notes'] . '<br />'; 
          } 
				 print($output); 
     }

Posted: Fri Dec 07, 2007 11:54 am
by feyd
Although I would describe the code as poorly formatted, I do not see a parse error right off.

What I do see is a few logic errors and a potentially undefined variable.

Posted: Fri Dec 07, 2007 12:07 pm
by 4Boredom
and thats what confuses me.. i dont think it would be blank unless it was parse?

Posted: Fri Dec 07, 2007 12:15 pm
by feyd
It's quite possible to not be a parse error and still not print anything. How? The query returns one row.

Posted: Fri Dec 07, 2007 12:30 pm
by 4Boredom
yes but its even killing all of my html above that

Posted: Fri Dec 07, 2007 12:47 pm
by feyd
Then that's not the whole code. You may have an error elsewhere.

If possible, test the code on a more local server (like your own machine) where you can control the error settings more easily.