Why does it not like this

  • tastysite
  • Proficient
  • Proficient
  • User avatar
  • Joined: Apr 09, 2008
  • Posts: 349
  • Loc: Brighouse, West Yorkshire, England
  • Status: Offline

Post January 6th, 2009, 8:22 am

I am using this php code
Code: [ Select ]
<?php if(isset($_GET['user']));{print "Hello ".$user." you are loged in!";}else{print "You are not loged in!";}?>
now it works upto the the point I try the put the else in then it says
Quote:
Parse error: syntax error, unexpected T_ELSE
. help
^__^
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post January 6th, 2009, 8:22 am

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23403
  • Loc: Woodbridge VA
  • Status: Offline

Post January 6th, 2009, 9:04 am

Lose the semicolon here
if(isset($_GET['user']));

Also I don't see where you defined $user anywhere.

Syntax for if/else conditional statements is roughly like this example

Code: [ Select ]
$number_three = 3;
 
if ( $number_three == 3 ) {
    echo "The if statement evaluated to true";
} else {
    echo "The if statement evaluated to false";
}
 
  1. $number_three = 3;
  2.  
  3. if ( $number_three == 3 ) {
  4.     echo "The if statement evaluated to true";
  5. } else {
  6.     echo "The if statement evaluated to false";
  7. }
  8.  


*note it's a lot easier to spot your problems if you have it on separate lines like that example versus all on one line like yours.

//side note "loged" should be spelled "logged"
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 130 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.