View Full Version : Problem with my include file

12-03-2010, 08:17 PM
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.
Parse error: syntax error, unexpected ',' in \gas\includes\functions.php on line 31

Here's the include file:

<?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';
$uName = mysql_real_escape_string(trim($username));
if (empty($pass)){
/*echo 'password empty \n'*/
$errors[] = 'You must enter a password';
$pass = mysql_real_escape_string(trim($pass));
/*If there are no errors to this point, run the query*/


$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

echo "<p> You have successfully registered. Try logging in below.</p>";
echo "<p class=\"error\"> There has been a login error. Please try again.</p>";
echo "<p class=\"error\">You need to login before adding a car to your garage</p>.";
echo "<p class=\"error\">You must login before viewing your records.</p>";
echo "<p class=\"error\">You must login before adding a fill up.</p>";


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*/

echo "UID is " . $data['UID'] . "<br />";
echo '<br />Started session';
// while($row=mysql_fetch_array($data)){
echo "success <br />";

/*When there is a successful login and the session has been started, redirect*/
$target = absolute_url('garage.php');

$errors = $data;



12-03-2010, 08:31 PM

parenthesis. or double quotes instead of single quotes.


12-03-2010, 08:46 PM
I tried it with
include ('includes/functions.php');
and include "includes/functions.php";

and I'm still getting the same error. :/

12-03-2010, 08:59 PM
I missed the part that the error was actually within "functions.php", not the include.

You're sure that you are showing us the correct "functions.php" script?
It would be the one in the "gas/includes" directory.

I don't see a problem at line 31 ... perhaps there is another "functions.php" file,
and you are picking it from the wrong directory? hmmmm

12-03-2010, 09:18 PM
I figured it out. In espresso, the file was within the includes folder, but on the server it wasn't. Once I uploaded everything again it worked fine. Dumb mistake on my part.

Thanks for helping me figure it out!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum