-
use PHP to edit txt
Hi guys, i have found a solution to making a chatroom...
i have a PHP script right? it says:
PHP Code:
<?php
//Reading the file
$file = fopen("count.txt", "r");
$count = fread($file, 1024);
fclose($file);
//Increasing the count
$count = explode("=", $count);
$count[1] = $count[1]+1;
//Writing to file
$file = fopen("count.txt", "w+");
fwrite($file, "count=".$count[1]);
fclose($file);
//Returning the count
print "count=".$count[1];
?>
that is PHP 3 code and what it does is it makes a textfile's variable called 'count' go up one. i use loadVariables to load this script into flash.
i don't have a proper understanding of PHP so i would like somebody to change this so that:
there is a variable inside called "mes". what i want to do is make it so that the variable mes is the message that somebody sends. i want to write this variable into the txt file, replacing the previous one.
please help, this solved will let me make a chatroom :D thank you to anybody who helps
-
http://www.jackleaman.co.uk/test/wri..._autoLoad.html
see if you can make use of the logic in this file :)
in a nutshell -
type your message
send to php
overwrite the text file
reload text to Flash and display
-
i am trying to find out the exact PHP script, i thought somebody could use the script i posted to change it...
but that link is great...
it'll help me make a guestbook!
i still want to make a chatroom though!!!
that link isn't so great after all... it won't even let me download it!
-
it's the same idea. I made a shoutbox using guestbook based php and a text file years ago. I just add a secondary variable for last post time. so if previous reload time is less than last post time, reload. So it kind of looks like a chatroom. When posting, rather than taking straight from flash += last post, you load the text file and write it in one go so you don't overwrite someone else's post at last second. One problem is when the text file gets really long, it will start to slow down. just be creative with them code.
-
i am only passing one variable and its the last message sent.
unfortunately it isn't working as planned, so i am going to check out a_modified_dog's zip!
-
hmmm.... this chatroom seems to not work. i think i will need somebody to help me write the php and flash script.
sorry people!
i am still getting the hang of php
and its hard for flash to work with php!
i looked at the zip but it isn't seeming to work???