|
|
|
|
![]() ![]() |
Aug 24 2005, 03:57 PM
Post
#1
|
|
|
Incest is a game the whole family can play. ![]() Group: [MODERATOR] Posts: 1,232 Joined: 11-February 05 From: Heaven Member No.: 3,709 myCENT:53.83 |
Hey all, I decided to write a script which writes some text to a file, but I have a problem when I execute the script, I get a fatal error:
QUOTE(homepage) Fatal error: Call to undefined function: file_put_contents() in /home/cmatcme/public_html/afile.php on line 55 This is the code I'm using to write the file: CODE $ipfnsdoc = "/home/cmatcme/public_html/afolder/afile.txt"; if (!is_readable($ipfnsdoc)) { echo "File cannot be read"; $stopload = 1; } if (!is_writable($ipfnsdoc)) { echo "<br>\nFile cannot be written to"; $stopload = 1; } if (!$stopload == 1) { $da_contents = file_get_contents($ipfnsdoc); if ($da_contents == NULL) { $da_contents = 0; } $towrite = $da_contents + 1; file_put_contents($ipfnsdoc,$towrite); } I've read php.net's documentation on the function and to be honest, I can't understand half of it, so can anyone please tell me what I'm doing wrong? |
|
|
|
Aug 24 2005, 05:58 PM
Post
#2
|
|
|
apt-get moo ![]() Group: [MODERATOR] Posts: 2,232 Joined: 28-May 05 From: Devon, England Member No.: 7,593 ![]() myCENT:64.27 |
First check that you have CHMOD 777 to the file and the folder it is in, which often requires moving it to a different folder of its own. There may also be a problem with the path /home/cmatcme/public_html/afolder/afile.txt
As far as I am aware, if the PHP script is in /home/cmatcme/public_html/afolder/ then you would write the path as just afile.txt I think it works just like HTML paths. You never put the literal file path in HTML, so you don't in PHP. Try changing it and see if it helps. It doesn't matter that you don't understand the docs |
|
|
|
Aug 24 2005, 06:53 PM
Post
#3
|
|
|
Incest is a game the whole family can play. ![]() Group: [MODERATOR] Posts: 1,232 Joined: 11-February 05 From: Heaven Member No.: 3,709 myCENT:53.83 |
Both the directory "afolder" and the file "afile.txt" are have 777 permissions. The file has the full url set because it's part of a page header file and so will be included in all files which will be in many different directories. Seeing as I don't have any subdomains or folders which require the inclusion of this file yet I'm gonna try anyway
====== No luck The contents of $towrite before it is set to be written into afile.txt is 1 and $ipfnsdoc should be the same as when it was set earlier on (afolder/afile.txt). I'm glad I've used the function correctly but also confused because if I am, how comes the error has arisen? |
|
|
|
Aug 25 2005, 07:19 AM
Post
#4
|
|
|
Ephesians 6:10-17 ![]() Group: [MODERATOR] Posts: 1,978 Joined: 22-June 05 From: somewhere... Where am i? Member No.: 8,528 myCENT:18.27 |
I think i know what the problem is. I looked up file_put_contents, and it said it's only for php5+, and i dont think Trap17 has that version installed. I think trap17 has v4.3.x. That's why you've been getting errors. You'll have to do it the old fashion way, with fopen, fwrite, and fclose.
|
|
|
|
Aug 25 2005, 09:30 AM
Post
#5
|
|
|
Incest is a game the whole family can play. ![]() Group: [MODERATOR] Posts: 1,232 Joined: 11-February 05 From: Heaven Member No.: 3,709 myCENT:53.83 |
That's probably it. I've tried using the fopen(), fwrite() and fclose() procedure and it works. Thank you truefusion and rvalkass for helping me
My problem has been solved so I will lock the topic. If you wish the topic to be reopened then please report the topic with a good reason... //Locked |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 21st November 2008 - 02:50 PM |