Page 1 of 1

[Solved] unexpected }

Posted: Mon Sep 05, 2005 11:03 am
by ericburnard
This is the code i have but for somereason the error is saying that its not expecting the } in the if command :S Is it something to do with the the loop i have inside the if function? :S

Code: Select all

Parse error: parse error, unexpected '}', expecting ',' or ';' in /home/madashat/public_html/eric/mail.php on line 56

Code: Select all

<? 
include('http://eric.madashatters.com/header.inc'); 
?> 

<?php 

if($_COOKIE[loggedin]){ 

// Connecting, selecting database 
mysql_connect('localhost', '*********', '*******') 
or die('Could not connect: ' . mysql_error()); 
mysql_select_db('madashat_mail') or die('Could not select database'); 


echo "<BR>"; 
$offset = $_GET['offset'];
if($offset == "") $offset = 0;
$max = $offset + 10;
$_SESSION['user'] = $username; 
$query = "SELECT * FROM pm WHERE user='$username' order by id desc"; 
$result = mysql_query($query) or die(mysql_error()); 
$rows = mysql_numrows($result);
if($max > $rows) $max = $rows;



echo "<center><u><b>Inbox</u></b><br><BR><a href='http://eric.madashatters.com/nm.php'>Return To Members Area</a> || <a href='http://eric.madashatters.com/sendmail.php?user=".$username."'>New Email Message</a> | <a href='http://eric.madashatters.com/sentmail.php?userm=".$username."'>Sent</a><br><table align='middle' cellpadding='5' style='border: dotted 1px'>
<tr> 
<td><div class='white'><u>Delete</u></td>
<td><div class='white'><u>New</u></td> 
<td><div class='white'><u>Date</u></td> 
<td><div class='white'><u>Subject</u></td> 
<td><div class='white'><u>Sender</u></td>"; 

for($i=$offset;$i<$max;$i++){

$subject = mysql_result($result,$i,"subject"); 
$new = mysql_result($result,$i,"new"); 
$message = mysql_result($result,$i,"message"); 
$date = mysql_result($result,$i,"date"); 
$sender = mysql_result($result,$i,"sender"); 
$id = mysql_result($result,$i,"id"); 

echo "<tr style='border: dotted 1px'>";
echo "<td><center><a href='/deletemail.php?mail=$id'><img src='delete.GIF' border='0'></a></center></td>";  
echo "<td><div class='white'>$new";
echo "</td>"; 
echo "<td><div class='white'>$date</td>"; 
echo "<td><div class='white'><a href='http://eric.madashatters.com/readmail.php?user=".$user."&mail=".$id."'>$subject</a></td>"; 
echo "<td><div class='white'>$sender</td>"; 
echo "</tr>"; 

}
echo "</table>"

} else {  // line 56 

echo "<center>Invalid Username Or Password <BR><BR><BR>
<form name='login' method='post' action='login.php'>
Username<br>
<input type='text' name='username'><BR>
Password<br>
<input type='password' name='password'><BR>
<input type='submit' name='submit' value='Submit'>
</form>";

}

?>  <BR><BR>
<? 
include('http://eric.madashatters.com/footer.inc'); 
?>
thanks again
Eric


feyd | descriptive titles help

[EDIT] Sorry :S

Posted: Mon Sep 05, 2005 11:13 am
by feyd
you're missing a semi-colon on the previous line.

side note: you really should quote named indices into array's, and including a url requires php to do a http page request (slowing your page down and making potential errors, along with security holes).

Posted: Mon Sep 05, 2005 11:16 am
by ericburnard
feyd wrote:you're missing a semi-colon on the previous line.

side note: you really should quote named indices into array's, and including a url requires php to do a http page request (slowing your page down and making potential errors, along with security holes).
ahhh thanks loads your great. i think i should have a read through arrays and have a playwith them.

Thnaks again
Eric

Posted: Mon Sep 05, 2005 11:23 am
by John Cartwright
indenting helps too 8)

Posted: Mon Sep 05, 2005 11:25 am
by ericburnard
Jcart wrote:indenting helps too 8)
Yea that comes after the page works :P

Posted: Mon Sep 05, 2005 11:34 am
by John Cartwright
ericburnard wrote:
Jcart wrote:indenting helps too 8)
Yea that comes after the page works :P
uhh, it will help prevent parse error prone mistake :roll:, not to mention organize your page better.