Calling functions in required files

Discussion in 'PHP' started by James WP, Feb 24, 2008.

  1. #1
    My file "login/index.php" begins with this code:

    <html><head><title>Login Test</title></head>
    <body>
    
    <?php
    
    require_once("../functions/functions_db.php");
    
    db_connect();
    Code (markup):
    The directory "functions" is on the same level as "login", so I'm telling the script to look up into the root directory from "login", then back down into "functions" to grab the required file.

    However, I get this error message:

    Suffice to say, "db_connect()" is a function in the required file, so does anyone know what I'm doing wrong?
     
    James WP, Feb 24, 2008 IP
  2. HuggyStudios

    HuggyStudios Well-Known Member

    Messages:
    724
    Likes Received:
    20
    Best Answers:
    26
    Trophy Points:
    165
    #2
    Well of course it is saying it cannot find that function, now are you 100% sure that the function has been named right?

    And your linking it is 100% correct?
     
    HuggyStudios, Feb 24, 2008 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #3
    ^ The path must be correct, because require_once() would trigger a fatal error an exit the script before it gets to the part where it calls the function.

    It's probably a silly error, like a spelling mistake in one of the functions or something.
     
    nico_swd, Feb 24, 2008 IP
    James WP likes this.
  4. zerxer

    zerxer Peon

    Messages:
    368
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Either that or the functions are in a class..? I know with my DB file, I have it in a DB class (which means I'd have to call the functions with $DB->query and such).
     
    zerxer, Feb 24, 2008 IP
  5. James WP

    James WP Active Member

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #5
    It was indeed silly. Phenomenally silly, ludicrously silly.

    The included file was missing the question mark from the opening <?php line.

    I hang my head in shame... :eek:
     
    James WP, Feb 24, 2008 IP