Hey, I’m making a chat using Flash MX & PHP and had it semi working last night but I changed some stuff this morning so each new message shows up on a new line and now it doesn’t seem to wanna work for me. Could someone look over my code for me? Its a long way from being finished but once I get the actual chat working it should come together fast.
Flash - Frame Code
getMSG = function() {
q = new LoadVars();
q.last = _global.last;
q.sendAndLoad("recieve.php",q,"GET");
q.onLoad = function() {
if (q.s == 1){
_global.msg = q.se + ": " + q.msg;
_global.last = q.l;
_root.chat.text = _root.chat.text + "
" + _global.msg;
} else {
_root.chat.text = "~Error Connecting To Server~";
}
}
}
_global.last = "0";
setInterval(getMSG,1000);
PHP - Recieve Messages Script
<?
#Load Community Settings
require("../config.php");
#Check is user is logged in
if (isset($HTTP_COOKIE_VARS['comm'])){
#Get username
$data = explode("|",$HTTP_COOKIE_VARS['comm']);
$user1 = $data[0];
#Get Variables From Flash
$last = $HTTP_GET_VARS['last'];
#Get New Messages
$connection =mysql_connect($host,$user,$pass) or die(mysql_error());
mysql_select_db($dbase,$connection);
$sql = mysql_query("SELECT * FROM Chat_Msgs WHERE ID > '$last'",$connection) or die("s=0");
if ($data = mysql_fetch_assoc($sql)) {
$sender = $data['user'];
$msg = $data['msg'];
$newlast = $data['ID'];
}
#Send Variaibles back to Flash
echo "s=1&l=$newlast&msg=$msg&se=$sender";
} else {
echo "s=0";
}
?>
When I run the chat I just get ‘~Error Connecting To Server~’ which means that my PHP is getting an error but when I run the PHP script using …/recieve.php?last=0 I don’t get any errors. Does anyone know what might be going wrong here?
Any Helps Appricated!