Jump to content

[SOLVED] Can anyone spot a mistake here? I can't!


onthespot

Recommended Posts

Hey guys, the SQL query works as I echoed the num rows and there are rows, I just don't think I am displaying very well?

 

<?php

$results = mysql_query("SELECT * FROM submittedresults where home_user = '$_SESSION[username]' or away_user = '$_SESSION[username]'");
$num_rows = mysql_num_rows($results);
if ($num_rows > 0)
{ 
	while( $row = mysql_fetch_assoc($results)) 
	{
	extract($row);
	$info = explode("_",$row[comp]);	
		if ( $user_submitted != $_SESSION[username]) 
		{
?>
			<div align="center">
			<table cellspacing="10" style='border: 1px dotted' width="300" bgcolor="#eeeeee">
			<tr>
			<td><b><? echo $info[2]; ?></b></td>
			</tr><tr>
			<td width="100"><? echo $home_user; ?></td>
			<td width="50"><? echo $home_score; ?></td>
			<td>-</td>
			<td width="50"><? echo $away_score; ?></td>
			<td width="100"><? echo $away_user; ?></td>
			</tr><tr>
			<td><A HREF="confirmresult.php?fixid=<? echo $fix_id; ?>">Accept / Decline</a></td>
			</tr></table></div><br>
<?
		}
	}


}
else
{
	echo "You currently have no results awaiting confirmation";
}

?>

 

Thankyou

Associative arrays should have single quotes around the keys.

 

Have you echoed inside your IF statements to ensure they are being reached?  Where is '$user_submitted' ever assigned a value?

 

Don't use shortags (), always use <?php.

its probably your associative array keys, as Maq has said. You probably have a mysql query error. Try doing

 

or die("ERROR: " . mysql_error());

 

after your query, and surround your associative array keys with single quotes

its probably your associative array keys, as Maq has said. You probably have a mysql query error. Try doing

 

or die("ERROR: " . mysql_error());

 

after your query, and surround your associative array keys with single quotes

 

That's what I was thinking because usually it throws an error saying that the keys aren't defined constants.  But the OP claimed that he echoed the num rows and it displayed...

The user submitted variable is defined by the extract(row).

Is there a way i can add into the sql WHERE user_submitte is not session[username].

That would remove that part from it?

Do you mean as in this?

 

WHERE user_submitte != '$_SESSION[username]'

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.