| | |
Php question
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
php Syntax (Toggle Plain Text)
<?php error_reporting(E_ALL ^ E_NOTICE); ini_set("display_errors", true); $file = "pets_feed_" . date("Ymd") . ".txt";// - for yyyymmdd if (!file_exists($file)) touch($file); $fh = fopen($file, "r"); $fcontent = fread($fh, filesize($file)); $towrite = "ID Category Description"."\n"; $fh22 = fopen($file, 'w+'); fwrite($fh22, $towrite . $fcontent); fclose($fh); fclose($fh22); ?>
Last edited by R0bb0b; Aug 29th, 2008 at 4:04 pm.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss
-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
•
•
•
•
php Syntax (Toggle Plain Text)
<?php error_reporting(E_ALL ^ E_NOTICE); ini_set("display_errors", true); $file = "pets_feed_" . date("Ymd") . ".txt";// - for yyyymmdd if (!file_exists($file)) touch($file); $fh = fopen($file, "r"); $fcontent = fread($fh, filesize($file)); $towrite = "ID Category Description"."\n"; $fh22 = fopen($file, 'w+'); fwrite($fh22, $towrite . $fcontent); fclose($fh); fclose($fh22); ?>
I get this error
Warning: fread() [function.fread]: Length parameter must be greater than 0 in /var/www/html/yumasun/media/gadzoo/txt.php on line 13
•
•
•
•
I get this error
Warning: fread() [function.fread]: Length parameter must be greater than 0 in /var/www/html/yumasun/media/gadzoo/txt.php on line 13
This should clear that up.
php Syntax (Toggle Plain Text)
<?php error_reporting(E_ALL ^ E_NOTICE); ini_set("display_errors", true); $file = "pets_feed_" . date("Ymd") . ".txt";// - for yyyymmdd if (!file_exists($file)) touch($file); $fh = fopen($file, "r"); $fcontent = ""; if(filesize($file) > 0) { $fcontent = fread($fh, filesize($file)); } $towrite = "ID Category Description"."\n"; $fh22 = fopen($file, 'w+'); fwrite($fh22, $towrite . $fcontent); fclose($fh); fclose($fh22); ?>
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss
-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
•
•
•
•
Your getting that because the file was just created so file size = 0. This doesn't mean it's not working it's just letting you know that fread won't read anything because there is nothing to read yet. Let me make one adjustment.
This should clear that up.
php Syntax (Toggle Plain Text)
<?php error_reporting(E_ALL ^ E_NOTICE); ini_set("display_errors", true); $file = "pets_feed_" . date("Ymd") . ".txt";// - for yyyymmdd if (!file_exists($file)) touch($file); $fh = fopen($file, "r"); $fcontent = ""; if(filesize($file) > 0) { $fcontent = fread($fh, filesize($file)); } $towrite = "ID Category Description"."\n"; $fh22 = fopen($file, 'w+'); fwrite($fh22, $towrite . $fcontent); fclose($fh); fclose($fh22); ?>
I dont get the error any more and is writting the file to the server but is only puttting this content
ID Category Description
is suppose to look like this
ID Category Description
456510 P115 JANDAY CONURE Very pretty, green/orange/blue, but keeps telling ME to shut up! $250/obo. 928-555-1212.
Thank you
•
•
•
•
I dont get the error any more and is writting the file to the server but is only puttting this content
ID Category Description
is suppose to look like this
ID Category Description
456510 P115 JANDAY CONURE Very pretty, green/orange/blue, but keeps telling ME to shut up! $250/obo. 928-555-1212.
Thank you
php Syntax (Toggle Plain Text)
<?php error_reporting(E_ALL ^ E_NOTICE); ini_set("display_errors", true); $file = "pets_feed_" . date("Ymd") . ".txt";// - for yyyymmdd if (!file_exists($file)) touch($file); $fh = fopen($file, "r"); $fcontent = @fread($fh, filesize($file)); $towrite = "ID Category Description"."\n"; $fh22 = fopen($file, 'w+'); fwrite($fh22, $towrite . $fcontent); fclose($fh); fclose($fh22); ?>
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss
-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
•
•
•
•
OK, use this then.
php Syntax (Toggle Plain Text)
<?php error_reporting(E_ALL ^ E_NOTICE); ini_set("display_errors", true); $file = "pets_feed_" . date("Ymd") . ".txt";// - for yyyymmdd if (!file_exists($file)) touch($file); $fh = fopen($file, "r"); $fcontent = @fread($fh, filesize($file)); $towrite = "ID Category Description"."\n"; $fh22 = fopen($file, 'w+'); fwrite($fh22, $towrite . $fcontent); fclose($fh); fclose($fh22); ?>
just writting ID Category Description to the file
Not for me, I copied that script, refreshed my page about 7 or 8 times and got this in pets_feed_20080829.txt
ID Category Description
ID Category Description
ID Category Description
ID Category Description
ID Category Description
ID Category Description
ID Category Description
ID Category Description
ID Category Description
which means that it is working fine.
ID Category Description
ID Category Description
ID Category Description
ID Category Description
ID Category Description
ID Category Description
ID Category Description
ID Category Description
ID Category Description
which means that it is working fine.
Last edited by R0bb0b; Aug 29th, 2008 at 5:27 pm.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss
-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
•
•
•
•
Not for me, I copied that script, refreshed my page about 7 or 8 times and got this in pets_feed_20080829.txt
ID Category Description
ID Category Description
ID Category Description
ID Category Description
ID Category Description
ID Category Description
ID Category Description
ID Category Description
ID Category Description
which means that it is working fine.
This is because the file is not re writting to the file is just writting but it needs to write
ID Category Description
and the petsfeed.txt contetn
Thank you
![]() |
Similar Threads
- PHP question regarding Forms (PHP)
- Integrating Php question (PHP)
- PHP question i think! (Site Layout and Usability)
- A php question (PHP)
Other Threads in the PHP Forum
- Previous Thread: Pagination help. Desperate
- Next Thread: Newbie PHP / MySQL Question
| Thread Tools | Search this Thread |
apache api array beginner binary broken cache cakephp checkbox class cms code confirm cron curl customizableitems database date display dynamic echo email error external fcc file files folder form forms forum freelancing function functions google header headmethod howtowriteathesis href htaccess html iframe image include insert ip javascript joomla limit link login mail malfunction menu method mlm mod_rewrite multiple mysql neutrality oop pageing pagerank paypal pdf php phpmysql play problem query question radio random recursion remote root script search select server sessions sms soap source space sql support! syntax system table template tutorial update upload url validator variable video web youtube





