Parse error: syntax error, unexpected T_ELSE

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
liyun88
Forum Commoner
Posts: 51
Joined: Thu Mar 31, 2011 12:18 pm

Parse error: syntax error, unexpected T_ELSE

Post by liyun88 »

hi,i face some problem.. when the user clicks the submit button and link to saveComment.php,i nid to check if the user is member,then can insert their comment in to database..but if the user not is member,then will pop out the messages..what wrong with my code??i gt the error that is Parse error: syntax error, unexpected T_ELSE..
can anyone help me to check and correct the code??thanks in advance..

Code: Select all

<?php

require_once 'config.php' ;
require_once 'application.php' ;

 $id = $_SESSION['id'];
$username = $_SESSION["username"];
$comment = $_POST["comment"];
if ($id = $_SESSION['id'])
{
$query = 'INSERT INTO comment set id =  "' . mysql_real_escape_string($id) . '",
username =  "' . mysql_real_escape_string($username) . '", 
comment =  "' . mysql_real_escape_string($comment) . '",date = "' . date('Y-m-d H:i:s') . '"'; 
$result = mysql_query($query);  
else{ 
  echo"<script>alert(\"Please register as member to comment\")</script>";
  }
  }
redirect("comment2.php");
?>
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: Parse error: syntax error, unexpected T_ELSE

Post by fugix »

you didnt end your if function with a } before starting your else statement
liyun88
Forum Commoner
Posts: 51
Joined: Thu Mar 31, 2011 12:18 pm

Re: Parse error: syntax error, unexpected T_ELSE

Post by liyun88 »

fugix wrote:you didnt end your if function with a } before starting your else statement
thanks ya...it works fine now.. :D
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: Parse error: syntax error, unexpected T_ELSE

Post by fugix »

no problem...;)
Post Reply