| View previous topic :: View next topic |
| Author |
Message |
Elec0 Expert Cheater
Reputation: 0
Joined: 21 Nov 2007 Posts: 188 Location: Out of my mind, back in five minutes.
|
Posted: Sun Dec 30, 2007 6:18 pm Post subject: [PHP] Problem with files |
|
|
I am having a problem creating, reading to, and writing to files. Here is my code:
| Code: |
$fh=fopen("/test/test.txt", "r");
if($fh==false)
die("unable to create file");
|
And, yes there is a folder called /test/.
I was wondering if someone could help me with this, I can't seem to figure it out.
Thanks,
~Elec0
_________________
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sun Dec 30, 2007 6:49 pm Post subject: |
|
|
Embrace your error with brackets:
| Code: | $fh=fopen("/test/test.txt", "r");
if($fh==false)
{
die("unable to create file");
} |
If the folder is named 'test' and the file is 'test.txt' you should probably just use:
| Code: | $fh=fopen("test/test.txt", "r");
if($fh==false)
{
die("unable to create file");
} |
If that doesn't work, try using the full path.
For more info and such on fopen:
http://us.php.net/manual/en/function.fopen.php
_________________
- Retired. |
|
| Back to top |
|
 |
Elec0 Expert Cheater
Reputation: 0
Joined: 21 Nov 2007 Posts: 188 Location: Out of my mind, back in five minutes.
|
Posted: Sun Dec 30, 2007 7:16 pm Post subject: |
|
|
Okay, thanks. I'll try that and see if it works.
Edit: Okay, I tried that code and it didn't work. I also tried the full path, (/test/test.txt.) That didn't work either.
~Elec0
_________________
|
|
| Back to top |
|
 |
|