Hi, everyone
I keep getting a parse error whenever the script gets to the include file. There is no ',' on line 31. It also always says line 31 even when I change the code so 31 is different.
Error:
Parse error: syntax error, unexpected ',' in \gas\includes\functions.php on line 31
Here's the include file:
PHP Code:
<?php /*Fill up functions */
/*This function validates form data*/
function check_login($username='', $pass=''){
$errors = array();/*initializes an error message array*/
/*Validate the username & password*/
if (empty($username)){
/*echo 'empty';*/
$errors[] = 'You must enter a username';
}else{
$uName = mysql_real_escape_string(trim($username));
}
if (empty($pass)){
/*echo 'password empty \n'*/
$errors[] = 'You must enter a password';
}else{
$pass = mysql_real_escape_string(trim($pass));
}
/*If there are no errors to this point, run the query*/
if(empty($errors)){
$sql = "SELECT uName, uLevel, UID FROM gf_users where uName = '$uName' and uPass = SHA1('$pass')";
$result = mysql_query($sql);
/*Check to make sure there's only one match*/
if (mysql_num_rows($result)=="1"){
$row = mysql_fetch_array($result);
return array(true, $row);
}else{/* If it didn't work*/
$errors[] = 'The username and password did not match those on file.';
}
}
return array(false, $errors); /*Returns the errors that caused problems*/
}/*Finish check login function*/
function userFillUp($UID=''){
$sql = "SELECT * FROM gf_fillUp WHERE UID = ".$UID;
$result = @mysql_query($sql);
$row = mysql_fetch_array($result);
return $row;
};
/*function check_garage($UID=''){}
/*function dynamically created a URL. The only thing it needs is the page that ends the URL*/
function absolute_url($page = ''){
$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
/*Remove any trailing slashes*/
$url = rtrim($url, '/\\');
/*Add the index page*/
$url .= '/' . $page;
return $url;
}
?>
Here's the login page if that helps. The include file that's causing a problem is on line 25
PHP Code:
<?php
if(!empty($_GET['m'])){
if($_GET['m']=="1"){
echo "<p> You have successfully registered. Try logging in below.</p>";
}
if($_GET['m']=="2"){
echo "<p class=\"error\"> There has been a login error. Please try again.</p>";
}
if($_GET['m']=="3"){
echo "<p class=\"error\">You need to login before adding a car to your garage</p>.";
}
if($_GET['m']=="4"){
echo "<p class=\"error\">You must login before viewing your records.</p>";
}
if($_GET['m']=="5"){
echo "<p class=\"error\">You must login before adding a fill up.</p>";
}
}
if(isset($_POST['submitted'])){
include "includes/include.php";
include "includes/con1.php";
echo "got here";
include 'includes/functions.php';
list($check, $data) = check_login($_POST['userID'], $_POST['password']);
echo $check;
if($check){/*everything worked*/
session_start();
echo "UID is " . $data['UID'] . "<br />";
echo '<br />Started session';
// while($row=mysql_fetch_array($data)){
$_SESSION['uName']=$data['uName'];
$_SESSION['UID']=$data['UID'];
$_SESSION['uLevel']=$data['uLevel'];
echo "success <br />";
//}
/*When there is a successful login and the session has been started, redirect*/
$target = absolute_url('garage.php');
header("Location:".$target);
exit();
}else{
$errors = $data;
};
mysql_close($con1);
}
include('includes/login_page.inc.php');
?>