Jump to content

Error That Is Somewhere But I Cant Seem To Find It


sweinkauf13
 Share

Recommended Posts

Hello,I'm writting a basic script to get some information out of a database table. The script name is inbox.php. Here is the error im getting: (directory modified for security): "Parse error: parse error in inbox.php on line 57". But i was looking and i cant find the error. Please help.

<?session_start();?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><title>Entertainment Zone!!!</title><link rel="stylesheet" type="text/css" href="style.css"></head><body><p><h1>EZ Messenger System</h1></p><p><h2><? echo("$_SESSION[username]"); ?>'s Inbox:</h2></p><center><p><?$con = @mysql_connect('server','username','password') or die(mysql_error());#$db = @mysql_select_db('entertainmentzone', $con) or die(mysql_error());#$username = "$_SESSION[username]";$sql = "select * from messages where to = '$username'";#$result = mysql_query("$sql", $con);#$num = mysql_num_rows($result);#if($num == "0"){echo("Inbox Empty");}else if($num > "0"){$inbox = "<table cellspacing=5 cellpadding=5 rules=all><tr><th>From</th><th>Subject</th><th>Date</th></tr>";#	while($row = mysql_fetch_array($result))	{$from = $row['from'];$subject = $row['subject'];$date = $row['date'];$status = $row['status'];#		if($status == "unread")		{$setting = "background-color=\"#151B54\"";		}else if($status == "read")		{$setting = "background-color=\"#2B3856\";		}		else		{$setting = "";		}#$inbox .="<tr $setting><td>$from</td><td>$subject</td><td>$date</td></tr>";	}$inbox .= "</table></p>";echo("$inbox");}?></body></html>

-youngwebmaster

Link to comment
Share on other sites

Dang it. Umm one last problem I ran into if you dont mind. I get a new error now "mysql_num_rows(): supplied argument is not a valid MySQL result resource in inbox.php on line 27";. How do I fix that? I've never seen it before.

Link to comment
Share on other sites

$result = mysql_query($sql, $con) or exit(mysql_error());Also, why do people write this:mysql_query("$sql", $con)when you could just do this:mysql_query($sql, $con)Why do you think you need to put quotes around $sql, but not around $con? Same with this:$username = "$_SESSION[username]";why not this:$username = $_SESSION['username'];Also, for things like this:else if($num > "0")You're comparing with a number, not a string. Leave out the quotes. You don't need to put quotes around everything.

Edited by justsomeguy
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...