Why does it not like this

  • tastysite
  • Proficient
  • Proficient
  • User avatar
  • Posts: 349
  • Loc: Brighouse, West Yorkshire, England

Post 3+ Months Ago

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
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

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"

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 70 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.