fread error
Posted by: benbs (---.red.bezeqint.net)
Date: December 15, 2006 10:30PM

i am trying to use this row in my file:
$data = addslashes(fread(fopen($form_data, "r"winking smiley, filesize($form_data)));
(there is no problems, im sure!)
and i get this error text:
Warning: fread(): supplied argument is not a valid stream resource in C:\wamp5\www\store.php on line 23

what i sopposed to do to make it work?
thanks, ben

Options: ReplyQuote
Re: fread error
Posted by: steveryherd (---.central.biz.rr.com)
Date: December 17, 2006 09:45PM

well, you have a lot going on in ONE line... if you want some debugging help try doing:

<?php

$form_data = $_SERVER['SCRIPT_FILENAME']; // Replace with your own $form_data after first try successfully works

header("Content-Type: text/plain"winking smiley; // Header makes data easier to read. Remove after debug
function divider(){ echo "\n\n"; for ($i=0; $i<80; $i++) echo "-"; echo "\n\n"; } // Function for creating dividers


if (is_array($form_data)) exit("Debug: Your data is an Array and won't be passed correctly"winking smiley;


// With the file commands divided like this you should be able to figure it out easier
$filehandler = fopen($form_data, "r"winking smiley;
$filesize = filesize($form_data);
$filecontents = fread($filehandler, $filesize);
echo "fopen was able to return:"."\n" . $filecontents;

echo divider();

// Also try an alternative method of grabbing file contents
// This will help you determine if file permissions.
$filecontents = file_get_contents($form_data);
echo "file_get_contents was able to return:\n" . $filecontents;


?>


What I suppose, is that you're sending an array into the $form_data;

Options: ReplyQuote


Sorry, only registered users may post in this forum.