sheraz Posted September 7, 2009 Share Posted September 7, 2009 hi sir i m working with fseek() and ftell(). i don't know what is the problem.i have just moved the position indicator 4 steps ahead and write the data on file. the code is correctly writing in the file but it is not displaying when i try to display it. here the code is.. reading the data from file. <?php if(! $fp=fopen("abc.txt", "w")) die("could not find the required file"); else { fseek($fp,4); fwrite($fp,"welcome to php programming"); } $file=fopen("abc.txt", "r"); $fi=ftell($file); fseek($file,$fi); echo fread($file,20); ?> it does not display anything. but data has been written on the file. please help me. :'( Quote Link to comment https://forums.phpfreaks.com/topic/173406-problem-with-fseek-and-ftell/ Share on other sites More sharing options...
Mark Baker Posted September 7, 2009 Share Posted September 7, 2009 Try closing the file after writing, before reopening it for read only Quote Link to comment https://forums.phpfreaks.com/topic/173406-problem-with-fseek-and-ftell/#findComment-914157 Share on other sites More sharing options...
ToonMariner Posted September 7, 2009 Share Posted September 7, 2009 after writing to the file close it as mark suggests but also clear the status cache (clearstatcache()) Quote Link to comment https://forums.phpfreaks.com/topic/173406-problem-with-fseek-and-ftell/#findComment-914164 Share on other sites More sharing options...
sheraz Posted September 16, 2009 Author Share Posted September 16, 2009 after writing to the file close it as mark suggests but also clear the status cache (clearstatcache()) Thanks buddy it is now working perfectly. i m very thankful to u. Quote Link to comment https://forums.phpfreaks.com/topic/173406-problem-with-fseek-and-ftell/#findComment-919411 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.