Parse error in a very simple program

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
underwood
Forum Newbie
Posts: 2
Joined: Tue May 06, 2014 4:34 am

Parse error in a very simple program

Post by underwood »

hi all. i searched and i did find that someone was facing this same problem. Although i did what was told to him, i am still getting the same error. guide me?

i have another php code written for storing username and respective passwords and i have saved it as passwords.php ( if any of this helps y'all)

Error i am getting -
Parse error: syntax error, unexpected 'exist' (T_STRING) in C:\wamp\www\ProjectCms\login.php on line 6

Code: Select all

<?php 
session_start(); 
include("passwords.php"); 
if ($_POST["ac"]=="log") { /// do after login form is submitted  
     if ($USERS[$_POST["username"]]==$_POST["password"]) { /// check if submitted 
     //username and password exist in $USERS array 
          $_SESSION["logged"]=$_POST["username"]; 
     } else { 
          echo'incorrect username/password. Please, try again.'; 
     }; 
}; 
if (array_key_exists($_SESSION["logged"],$USERS)) { //// check if user is logged or not  
     echo "You are logged in."; //// if user is logged show a message  
} else { //// if not logged show login form 
     echo '<form action="login.php" method="post"><input type="hidden" name="ac" value="log"> '; 
     echo 'Username: <input type="text" name="username" />'; 
     echo 'Password: <input type="password" name="password" />'; 
     echo '<input type="submit" value="Login" />'; 
     echo '</form>'; 
}; 
?>
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Parse error in a very simple program

Post by Christopher »

It looks like the comment "//username and password exist in $USERS array" is not being parsed as a comment for some reason. Check the file to see why. Test by removing it.
(#10850)
underwood
Forum Newbie
Posts: 2
Joined: Tue May 06, 2014 4:34 am

Re: Parse error in a very simple program

Post by underwood »

thanks for the reply christopher.
What you suggested isn't working.
Its still giving me the same error.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Parse error in a very simple program

Post by Celauran »

That's the only instance of 'exist' in that document. It's giving the same error after having removed it?
Post Reply