Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Useing Php functions

  • 31-03-2006 08:03PM
    #1
    Registered Users, Registered Users 2 Posts: 353 ✭✭


    I'm pretty much a novice at Php programming (My project team's regular Php programmer had to leave) and I'm struggeling to get a function to work.

    "Fatal error: Call to undefined function: writefile()"

    <?php
    session_start();
    .
    .
    .
    function writeFile(){
    $fileName = $HTTP_SESSION[exam];

    $ourFileHandle = $fopen($fileName, "w");
    $someData = "***".$HTTP_SESSION_VARS[exam]."***".$HTTP_SESSION_VARS["ex1"]."***".$HTTP_SESSION_VARS["ex2"]."***".$HTTP_SESSION_VARS["ex3"]."***";

    fwrite($ourFileHandle, $someData );

    fclose($ourFileHandle);
    }
    .
    .
    .
    writeFile();
    session_destroy();
    }
    }
    ?>
    </body>
    </html>



    Can anybody give me any tips regarding this error message?
    Are there limitations on where functions can be declared? Or could there be a proble with useing SESSION variables within the function?

    As I said I know very little Php so any help would be appreciated.
    Thanks.

    edited to include code.


Comments

  • Registered Users, Registered Users 2 Posts: 32,132 ✭✭✭✭is_that_so


    Please paste some code to show where your problem is. The error generally means it can't find it.

    If it is a file you want to write to, use fwrite() . Also check out www.php.net for functions.


  • Registered Users, Registered Users 2 Posts: 919 ✭✭✭timeout


    Are there any other functions in the same code?Do they execute ok?
    Normally i'd define most of my functions in a sepearte file and just include them or if defining in the file would keep them at the top.
    Should not be a problem using session variables within the function.
    A call to an undefined function just means it doesn't know about the function, generally its a case of missing a ; or a }
    I see you are missing "" here:
    $HTTP_SESSION_VARS[exam]


Advertisement