Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Useing Php functions

Options
  • 31-03-2006 8:03pm
    #1
    Registered Users Posts: 354 ✭✭


    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 Posts: 32,136 ✭✭✭✭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 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