Keep getting a Parse error: syntax error, unexpected T_EXIT
Hi guys wondering if I can get some help...
Ive just started doing a small e commerce site.
I have tried to to setup a simple form where the user would enter details and login. However, I am getting this message when trying to view my page in a browser.
"Parse error: syntax error, unexpected T_EXIT in C:\####\####\####\####\####\admin_login.php on line 5"
Here is the code:
Thanks before hand for any help, much appreciated.
<?php
// Run script after user has clicked 'log in'
if (isset($_POST["username"]) && isset($_POST["password"])) {
$manager = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["username"]);
$password = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["password"]);
// Connecting to database
include "/Scripts/Connection_MySQL.php";
$sql = mysql_query("SELECT id FROM tblAdmin WHERE username='$manager' AND password='$password' LIMIT 1"); // query the person
//Ensuring user existence
$existCount = mysql_num_rows($sql);
if ($existCount == 1) {
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
}
$_SESSION["id"] = $id;
$_SESSION["manager"] = $manager;
$_SESSION["password"] = $password;
header("location: index.php");
exit();
} else {
echo 'That information is incorrect, try again <a href="index.php">Click Here</a>';
exit();
}
}
?>
Last edited by bradgrafelman; 03-21-2013 at 06:59 PM.
Reason: bbcode tags modified
Welcome to PHPBuilder! When posting PHP code, please use the board's [php]..[/php] bbcode tags (versus the generic CODE tags) as they make your code easier to read and analyze.
As for your issue... the statement preceding the one identified in the error message is missing a terminating semicolon.
Can you show us what the first few statements of the file look like with the added semicolon? When I added it, a lint check showed no further parse errors.
<?php
session_start();
if(!isset($_SESSION["manager"])){
header("location: index_store_admin.php"); // added semicolon at the end here
exit();
}
?>
<?php
// Run script after user has clicked 'log in'
if (isset($_POST["username"]) && isset($_POST["password"])) {
$manager = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["username"]);
$password = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["password"]);
// Connecting to database
include "/Scripts/Connection_MySQL.php";
$sql = mysql_query("SELECT id FROM tblAdmin WHERE username='$manager' AND password='$password' LIMIT 1"); // query the person
//Ensuring user existence
$existCount = mysql_num_rows($sql);
if ($existCount == 1) {
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
}
$_SESSION["id"] = $id;
$_SESSION["manager"] = $manager;
$_SESSION["password"] = $password;
header("location: index.php");
exit();
} else {
echo 'That information is incorrect, try again <a href="index.php">Click Here</a>';
exit();
}
}
?>
Bookmarks