Help for simple PHP script |
Help for simple PHP script |
denmarks |
Aug 26 2018, 03:50 PM
Post
#1
|
Advanced Member Group: Members Posts: 207 Joined: 17-January 08 Member No.: 4,734 |
I know hardly anything about PHP and am trying to create a very simple script. It is the beginning of a web counter.
There is a file named count.log that has a single line in it with a zero (0). I want to read the file and create a gif displaying the number. One is then added to the count and it is written back to the log file. The gif displays but I do not believe the the log is read or written. The value of 0 appears which is what I initialize the log file to. CODE <?php $count_file = 'count.log'; $my_img = imagecreatefromgif ("count.gif"); $textcolor = imagecolorallocate($my_img, 0, 0, 0); $count = 0; file_get_contents($count_file, $count); imagestring($my_img, 4, 2, 3, "Counter $count", $textcolor); $count = $count + 1; file_put_contents($count_file, $count); header( "Content-type: image/png" ); imagepng( $my_img ); imagedestroy( $my_img ); ?> |
Christian J |
Aug 27 2018, 01:37 PM
Post
#2
|
. Group: WDG Moderators Posts: 9,653 Joined: 10-August 06 Member No.: 7 |
Have you made the log file writable with CHMOD (usually done with the FTP program)?
|
denmarks |
Aug 27 2018, 02:17 PM
Post
#3
|
Advanced Member Group: Members Posts: 207 Joined: 17-January 08 Member No.: 4,734 |
Have you made the log file writable with CHMOD (usually done with the FTP program)? I looked at the file permissions and it is read, write, and execute. That was the default. Does the type of "log" have any special meaning? I can change it. You can run my file at http://www.dmmarks.com/count.php Maybe you can see errors I do not see. |
Christian J |
Aug 27 2018, 03:52 PM
Post
#4
|
. Group: WDG Moderators Posts: 9,653 Joined: 10-August 06 Member No.: 7 |
|
denmarks |
Aug 27 2018, 04:07 PM
Post
#5
|
Advanced Member Group: Members Posts: 207 Joined: 17-January 08 Member No.: 4,734 |
I looked at the file permissions and it is read, write, and execute. That was the default. For Owner? Maybe you also need write permission for Group, depending on the server configuration (IIRC). Owner, Group, and Public are all the same. Since I am new to PHP I have no idea where to start. Can someone copy all the files and test it on their site? |
Lo-Fi Version | Time is now: 19th April 2024 - 08:53 PM |