#1
  1. No Profile Picture
    Super Moderator
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2009
    Location
    Hartford, WI
    Posts
    1,435
    Rep Power
    24

    Error from function that's not called


    I'm even trying to load a rather blank page to test around this, but even if the page has no actions to it, I have 1 line in a function that is erroring out, failing the page load. Since this page has no action, other than basic hard-coded logo/navigation/footer, why is a line from a function that's not called failing?

    The error:
    Parse error: syntax error, unexpected '$hash' (T_VARIABLE), expecting ',' or ')' in ...\inc\functions.php on line 22

    The main page's include/reference to the file containing the issue'ed line:
    PHP Code:
    <?php include('./inc/functions.php'); $page_id = isset($_GET['page_id']) ? $_GET['page_id'] : 0$data build_main_content($page_id); ?><!DOCTYPE...
    The function:
    PHP Code:
    function user_login($user$pass) {
      global 
    $link;
      
    $select_user $link->prepare('SELECT password FROM users WHERE username = ?;');
      
    $select_user->bind_param('s'$user);
      
    $select_user->execute();
      
    $select_user->bind_result($hash);
      
    $select_user->fetch();
      
    $select_user->close();
      
    $valid password_verify($pass, $hash);
      if(
    $valid) {
      } else {
      }

    The line being referenced/erroring: (Function not even called...)
    PHP Code:
    $valid password_verify($pass, $hash); 
    Any assistance would be greatly appreciated. Thank you!

    EDIT: If I comment out that one line for testing, pages load fine...[/B]

    EDIT2: My main body's container currently holds its info in the database and presented as below, but the functions are in a file include...
    PHP Code:
        <DIV class="container" id="content_wrapper">
    <?php echo eval("?>".$data['content']); ?>
        </DIV>
    Body's content fetch function:
    PHP Code:
    function build_main_content($id) {
      global 
    $link;
      
    $fetch_content $link->prepare('SELECT title, content FROM content WHERE id=?;');
      
    $fetch_content->bind_param('i'$id);
      
    $fetch_content->execute();
      
    $fetch_content->bind_result($data['title'], $data['content']);
      
    $fetch_content->fetch();
      
    $fetch_content->close();
      return 
    $data
    Last edited by Triple_Nothing; February 27th, 2017 at 09:56 AM.
    He who knows not that he knows not is a fool, ignore him. He who knows that he knows not is ignorant, teach him. He who knows not that he knows is asleep, awaken him. He who knows that he knows is a leader, follow him.
  2. #2
  3. Forgotten Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,091
    Rep Power
    9644
    It's a parse error, not a runtime error. When PHP loaded the file it parsed everything (as it must do) but it had a problem with that line.

    Delete the line and type it out again? Maybe some bad character slipped in there.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,279
    Rep Power
    629
    Its a compile error not a run time error. Where the actual problem lies is likely elsewhere. Probably a missing/misplaced ';' some bracket type.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  6. #4
  7. No Profile Picture
    Super Moderator
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2009
    Location
    Hartford, WI
    Posts
    1,435
    Rep Power
    24
    Hmmm.... Well, I did think of the elsewhere idea, but saw nothing, and commenting the line out temporary solved the error. I ended up just removing that and the above/below line to be safe and typed them fresh. Everything works perfectly fine now. Must've been a hidden/invisible character or something. *shrugz*

    Thanks for the noting of it being a parse/compile and not a runtime. That kinda made my view run the right path.
    He who knows not that he knows not is a fool, ignore him. He who knows that he knows not is ignorant, teach him. He who knows not that he knows is asleep, awaken him. He who knows that he knows is a leader, follow him.

IMN logo majestic logo threadwatch logo seochat tools logo