3raser Posted February 11, 2012 Share Posted February 11, 2012 $file = 'includes/views.txt'; $f = fopen($file, 'w+'); $views = fread($f, filesize($file)); fwrite($f, $views+1); fclose($f); The contents of views.txt is: 1 Why is it returning it needs to be greater than 0?...The file isn't empty. Quote Link to comment https://forums.phpfreaks.com/topic/256911-length-parameter-must-be-greater-than-0/ Share on other sites More sharing options...
3raser Posted February 11, 2012 Author Share Posted February 11, 2012 Forgot the error: Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home/content/63/8895563/html/index.php on line 6 Quote Link to comment https://forums.phpfreaks.com/topic/256911-length-parameter-must-be-greater-than-0/#findComment-1317073 Share on other sites More sharing options...
requinix Posted February 11, 2012 Share Posted February 11, 2012 Check the PHP manual for exactly what the w+ mode means: 'w+' Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it. Quote Link to comment https://forums.phpfreaks.com/topic/256911-length-parameter-must-be-greater-than-0/#findComment-1317087 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.