The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Problem Reading Files

I'm trying to create a script to read the contents of a text file submitted in a form into a variable, for use elsewhere. I'd prefer not to have to save the file to the server if at all possible. However, I've wasted a fair whack of this morning trying in vain to accomplish this. I'm at a pretty basic level, so if anyone can ignore my idiocy, and help, it would be much appreciated.

What I've been fiddling with is as follows:

PHP Code:

<?php

extract($_REQUEST);
extract($_FILES);

?>

<html>
<body>
<p>

<?php

if(isset($news_sql)) {
echo("hello");
}

$file = fopen($news_sql, r);
$test = fpassthru($file);

echo("test");
echo("$test");

?>

</p>
</body>
</html>

And I get the following error messages:

Warning: fopen() expects parameter 1 to be string, array given in /home/hsphere/local/home/msweeney/msweeney.k39.kfmcrthy.com/cms/test5.php on line 18

Warning: fpassthru(): supplied argument is not a valid stream resource in /home/hsphere/local/home/msweeney/msweeney.k39.kfmcrthy.com/cms/test5.php on line 19

Can anyone can point me in the right direction, or to a tutorial that might help? Thanks in advance.

First the function fopen() expects the name of a file. Apparently according to the warning your passing it an array. the question is what is $news_sql? I'm assuming its from your form but how exactly does your form work. What exactly does extract() do? I can make guesses but its easier if you explain what it does. Thanks.