Forum Moderators: coopster
My partner coder, whose account I'm writing from, went to vacation for almost two weeks and left me helpless with an error that appeard after our host switched to newer php version.
Warning: Wrong parameter count for fread() in /home/www/somename/setup1.php on line 1390
I spent two days reading different forums and manuals trying to figure this out. aparantly the problem in newer version is that the file can not be 0 bytes. I tried to add couple of symbols to the file, but could not edit it since only the server have permissions to alter it. It has -rw-r-r mode with server ownership.
He is the code I belive which creates this statistic file:
$postfile = "feeds/post_HTML".$codeFile.".txt";
if (!file_exists($postfile)) {
session_unset();
header("Location: [somesite.com...]}
$fp = fopen($postfile, "r");
$file_contents = fread($fp, filesize($postfile));
fclose($fp);
$statisticsFile = "feeds/count_feeds.sta";
$feeds_count = 0;
if (file_exists($statisticsFile)) {
$fp = fopen($statisticsFile, "r");
$feeds_count = fread($fp, filesize($statisticsFile));
fclose($fp);
}
$orders_count++;if ($fp = fopen("$statisticsFile", 'w')) {
fwrite ($fp, $feeds_count);
}
fclose($fp);$to_send.=$file_contents;
Please could someone let me know what is a possible solution.
Thanks
In PHP 4.2.0 and later, the default value for the PHP directive register_globals is off. This is a major change in PHP. Having register_globals off affects the set of predefined variables available in the global scope. For example, to get DOCUMENT_ROOT you'll use $_SERVER['DOCUMENT_ROOT'] instead of $DOCUMENT_ROOT, or $_GET['id'] from the URL http://www.example.com/test.php?id=3 instead of $id, or $_ENV['HOME'] instead of $HOME.
After the code I posted follows a payment form with this element in it:
<form name=\"info\" onsubmit=\"return msab();\" action=\"https://id111.somesecureserver.net/somesite/base.php\" method=\"post\"><input type=\"hidden\" name=\"shop_action\" value=\"process_order\">
So I beleive it does pull froma form. The codeFile is being declared earlier:
function submit_order() {global $cart;
global $codeFile;
Later in the code after the order form I found for functions:
$postfile = "feeds/post_Plane".$codeFile.".txt";
$fp = fopen($postfile, "r");
$plane = fread($fp, filesize($postfile));
//$to_send.=$plane;
fclose($fp);
$postfile = "feeds/post_Price".$codeFile.".txt";
$fp = fopen($postfile, "r");
$totalPrice1 = fread($fp, filesize($postfile));
fclose($fp);
But the error apears before the the form is processed right after a customer is sent to a secure server.
I'm sorry if I sound newbish, but scripting is my poor side.
$feeds_count = fread($fp, filesize($statisticsFile));
Thanks
I tried to add a little weight to the file with this:
$feeds_count = fread($fp, filesize($statisticsFile, 8092));
But it gave me another error next to the first one:
Warning: Wrong parameter count for filesize() in /home/www/veneerz/setup1.php on line 1390
[edited by: Artstart at 6:24 pm (utc) on April 13, 2006]
//$fp = fopen($postfile, "r");
//$file_contents = fread($fp, filesize($postfile));
$file_contents = file_get_contents($postfile);
//fclose($fp);
no open or close needed, just the single line using file_get_contents [php.net]
as noted on the page for fread [php.net]
Note: If you just want to get the contents of a file into a string, use file_get_contents() as it has much better performance than the code above.