Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-03-2010, 07:17 PM   PM User | #1
daveduq
New to the CF scene

 
Join Date: Dec 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
daveduq is an unknown quantity at this point
Question Problem with my include file

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');

?>
daveduq is offline   Reply With Quote
Old 12-03-2010, 07:31 PM   PM User | #2
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,042
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
include('includes/functions.php');

parenthesis. or double quotes instead of single quotes.



.
mlseim is offline   Reply With Quote
Old 12-03-2010, 07:46 PM   PM User | #3
daveduq
New to the CF scene

 
Join Date: Dec 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
daveduq is an unknown quantity at this point
I tried it with
include ('includes/functions.php');
and include "includes/functions.php";

and I'm still getting the same error. :/
daveduq is offline   Reply With Quote
Old 12-03-2010, 07:59 PM   PM User | #4
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,042
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
oh,
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
mlseim is offline   Reply With Quote
Old 12-03-2010, 08:18 PM   PM User | #5
daveduq
New to the CF scene

 
Join Date: Dec 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
daveduq is an unknown quantity at this point
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!
daveduq is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:16 PM.


Advertisement
Log in to turn off these ads.