I am making a script and i came upon a need to overwrite a file rather than just add to it. I am using $file = @fopen($filename, "w"); but that just adds. Does anyone know the code to overwrite? Thanks for the help
I am making a script and i came upon a need to overwrite a file rather than just add to it. I am using $file = @fopen($filename, "w"); but that just adds. Does anyone know the code to overwrite? Thanks for the help
http://us3.php.net/fopen
PHP Code:$file = @fopen($filename, "w+");
I actually tried that before and it didn't work. I also just tried it again and still no goodOriginally Posted by blm126
. By what it says on that page, a simple "w" should work too, but it doesn't. Anyone know whats wrong?
Your right, "w" should be enough. But "that page" is the PHP manual, and I'm pretty sure it is right sooooo. Make sure
- Safe mode is not enabled(or that the PHP user is the owner of the file)
- $filename is NOT a URL eg. http://www.blah.com
- fopen() is not failing. Remove the "@' in front of fopen to find out
Ok, i made sure of the second 2 things you said and they check out, but I have cpanel and I am not sure how to check safe mode. Do I just talk to my host? thanksOriginally Posted by blm126
You could make a php page with
and it will say if Safe Mode is enabled. If so, being that you use CPanel, I doubt that your webhost will disable it, but every webhost is different.PHP Code:<?
phpinfo();
?>
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design
Always a good way to find things out, but phpinfo() will tell you. If you could post your complete code I might be able to find the problemOriginally Posted by Titan85
Ok, i ran the phpinfo() script and didn't see anything saying safe mode was enabled. Here is the php info http://echodesign.jexhost.com/testing/test.php
It is disabled. I am going to see more code to find the problem
Do you mean you need some of the script code? Also, could the file to write to being a .txt be a problem?Originally Posted by blm126
Bookmarks