Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    ?>

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,456
    Thanks
    8
    Thanked 1,084 Times in 1,075 Posts
    include('includes/functions.php');

    parenthesis. or double quotes instead of single quotes.



    .

  • #3
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I tried it with
    include ('includes/functions.php');
    and include "includes/functions.php";

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

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,456
    Thanks
    8
    Thanked 1,084 Times in 1,075 Posts
    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

  • #5
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •