PDA

View Full Version : problem with AS and PHP



λ
July 25th, 2003, 08:12 AM
I'm using AS and PHP in a guestbook, and it doesn't seem to be working. I've tried everything I can think of.
Here is the PHP code


<?php
if(!file_exists("guestbook.txt")){
print "entries=0";
exit();
}else{
$wholeFile = file_get_contents("guestbook.txt");
print ("entries=".$wholeFile);
}
?>

basically, as you can see, this just takes data out of a text file and prints it.

the data is written to the textfile separated by |(denotes a new entry) and #(denotes a username), for example
'This site is really cool!#njs12345|It is, isn't it!#kirupa'

this is the AS I am using:


scroll_txt = textScroller_mc.scroll_txt;
guestbookLoad_lv = new LoadVars();
guestbookLoad_lv.load("guestBookRead.php");
guestbookLoad_lv.onLoad = function(success) {
if (success) {
textLoaded = guestbookLoad_lv.entries;
if (textLoaded="0") {
scroll_txt.htmlText = "Sorry, there are no entries in the guestbook at this time.";
} else {
if (textLoaded.indexOf("|" == -1)) {
textLoaded.split("&");
scroll_txt.htmlText += "<br>";
scroll_txt.htmlText += textLoaded[1];
scroll_txt.htmlText += "<br>";
scroll_txt.htmlText += "posted by "+"'"+textLoaded[2]+"'.";
} else {
textloaded.split("|");
for (var i = 0; i<textLoaded.length; i++) {
textLoaded[i].split("#");
}
for (var i = 0; i<textLoaded.length; i++) {
scroll_txt.htmlText += "<br>";
//just some scroller code
scroll_txt.htmlText += textLoaded[i][1];
scroll_txt.htmlText += "<br>";
scroll_txt.htmlText += "posted by "+"'"+textLoaded[i][2]+"'.";
}
}
}
} else {
scroll_txt.htmlText = "Sorry, an error has been encountered.";
}
};
stop();
with (textScroller_mc) {
scrollUp_btn.onRelease = function() {
if (scroll_txt.scroll>1) {
scroll_txt.scroll--;
}
};
scrollDown_btn.onRelease = function() {
if (scroll_txt.scroll<scroll_txt.maxscroll) {
scroll_txt.scroll++;
}
};
}
submit_btn.onRelease = function() {
gotoAndStop("frame2");
};

e.s.x.s
July 25th, 2003, 04:30 PM
try to change this line:

if (textLoaded.indexOf("|" == -1)) {

to:

if (textLoaded.indexOf("|") == -1) {


e.s.x.s

λ
July 25th, 2003, 05:30 PM
Yeah- I made loads of errors, but I fixed it now.