sweinkauf13 Posted August 19, 2009 Report Share Posted August 19, 2009 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 More sharing options...
justsomeguy Posted August 19, 2009 Report Share Posted August 19, 2009 You missed a quote on line 53. Link to comment Share on other sites More sharing options...
dsonesuk Posted August 19, 2009 Report Share Posted August 19, 2009 $setting = "background-color=\"#2B3856\"; should be $setting = "background-color=\"#2B3856\""; Link to comment Share on other sites More sharing options...
sweinkauf13 Posted August 19, 2009 Author Report Share Posted August 19, 2009 o. haha now i see it. thanks. i feel kinda embarrest and blind. but thanks.i appreciate it. Link to comment Share on other sites More sharing options...
sweinkauf13 Posted August 19, 2009 Author Report Share Posted August 19, 2009 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 More sharing options...
dsonesuk Posted August 19, 2009 Report Share Posted August 19, 2009 you have a table field name of 'to' ?$sql = "select * from messages where to = '$username'"; Link to comment Share on other sites More sharing options...
sweinkauf13 Posted August 19, 2009 Author Report Share Posted August 19, 2009 ya. i do have a table field named 'to'. Link to comment Share on other sites More sharing options...
dsonesuk Posted August 19, 2009 Report Share Posted August 19, 2009 (edited) should $result = mysql_query("$sql", $con); be $result = mysql_query("$sql", $db);forget this, i connect to database using a different method compared to yours. Edited August 19, 2009 by dsonesuk Link to comment Share on other sites More sharing options...
justsomeguy Posted August 19, 2009 Report Share Posted August 19, 2009 (edited) $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 August 19, 2009 by justsomeguy Link to comment Share on other sites More sharing options...
sweinkauf13 Posted August 21, 2009 Author Report Share Posted August 21, 2009 Ok i've implemented the things you all have said. It works now. Thanks for everything.-Youngwebmaster Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now