hi everyone, I keep getting the following error when I try to open up an uploaded file.

Fatal error: Function name must be a string in /home/********/public_html/upload_file.php on line 42

I want to use $fgetcsv() on it but I can't seem to pass a proper argument to it. here is my code

/*save the file on the server since by default PHP deletes file on script exit*/
if ($_FILES["file"]["error"] > 0){
    echo "<h2>File upload error; Return Code: " . $_FILES["file"]["error"];
	echo "  Please contact your IT admin </h2>";   
exit(); } /*verify to make sure it doesn't exist already*/ if (file_exists("_Uploaded/" . $_FILES["file"]["name"])){ echo "<h2> the file " . $_FILES["file"]["name"] . " already exists." . " Please rename and upload again</h2>";
exit(); } else{ /*save uploaded file locally in folder for it */ move_uploaded_file($_FILES["file"]["tmp_name"], "_Uploaded/" . $_FILES["file"]["name"]); echo "<h2>Thank you the file: " . $_FILES["file"]["name"]; echo " was successfully uploaded and accepted</h2>"; } [color="red"]/*open the file for reading so we can work on it*/ $uploadedFile = "_Uploaded/" . $_FILES["file"]["name"]; $fileResource = $fopen($uploadedFile,'r');[/color]

    There is no such function $fgetcsv/b in the code you showed us.

    Perhaps you meant [man]fgetcsv/man instead?

    EDIT: Same goes for $fopen/b vs. [man]fopen/man.

      Thank you Brad. lesson learned. I was calling a php function like a variable name by prefacing the function with a '$'.

      thanks again.

        Don't forget to mark this thread resolved (if it is) using the link on the Thread Tools menu above.

        Also note that what you were doing is actually valid syntax, e.g.:

        $fopen = 'fopen';
        $fp = $fopen('file.txt', 'r');

        is the same as:

        $fp = fopen('file.txt', 'r');
          bradgrafelman;10982010 wrote:

          Don't forget to mark this thread resolved (if it is) using the link on the Thread Tools menu above.

          Also note that what you were doing is actually valid syntax, e.g.:

          $fopen = 'fopen';
          $fp = $fopen('file.txt', 'r');

          is the same as:

          $fp = fopen('file.txt', 'r');

          Yeah i see what you're saying. The only thing is i didn't assign the function fopen() to a variable and then use it. I called it like a variable.

          Either way i called it correctly this time and it took the argument. Still a weird error message though.
          Thank you.

            Write a Reply...