PDA

View Full Version : Flash ignoring vars sent from PHP !!!



SteveD
March 25th, 2004, 02:55 PM
Hi,
I am having a serious prob getting flash to read a var sent by php, there is a thread HERE (http://www.kirupaforum.com/forums/showthread.php?s=&threadid=51162) that addresses the same problem, but after following that I still cannot get the thing to work, so without further ado her is my code


<?php
include("connect_1.php");

$pWord = $_POST['pWord'];



$query = "SELECT name,entryCount FROM $table WHERE pWord = '$pWord'";
$result=mysql_query($query);
if(mysql_num_rows($result)){
$row=mysql_fetch_array($result);
$name=$row['name'];
$entryCount = 1;

echo '&name=' . urlencode($name);
print '&entryCount='.urlencode($entryCount);
}
else
{
$entryCount = 2;
echo '&entryCount='.urlencode($entryCount);
}
mysql_close($link);
?>

All the above works well the DB is read and the vars are passed back to Flash - I have used dtb's and trace to check this
My Flash code is

function bsReg()
{
entryLVs = new LoadVars()
entryLVs.pWord = pWord.text;
entryLVs.onLoad = function(success)
{
if(success)
{

name = this.name;
entryCount = this.entryCount;
//this if statement is being complmetely iignored
if(entryCount == 1)
{
//do something
}
else if(entryCount == 2)
{
//do something else;
}

}
}
entryLVs.sendAndLoad("scripts/BSentry.php", entryLVs, "POST");
}

Anyway thats about it, simple enough, nothing complicated, but the if statement is just not being read, I have tried everything and it is driving me nuts, any help greatly appreciated

Cheers

SteveD

kill.robot.kill
March 25th, 2004, 03:28 PM
the numbers are being passed to flash as a string, so either convert the 1 and the 2 into integers, once they are received in flash, or add quotes around them in your if statement, to accommodate for them being strings.

SteveD
March 25th, 2004, 03:46 PM
Hi,
yep, I tried it both ( all ) ways and still could not get it to work, however reviewing the post that I linked to above, the ampersand did it !! Finally. I changed my code to this


echo '&name=' . urlencode($name)."&";
echo '&entryCount='.urlencode($entryCount)."&";

and it works fine now, not sure I understand why

Thanks for taking the time

Cheers

SteveD