PDA

View Full Version : php = i'm retarded


Duffman
01-25-2005, 04:35 AM
ok, i know this is probably the smallest mistake, but i've been looking for an hour, and it all seems to be right. i'm trying to load data into flash from a php scipt. here is my php:
<?
$moo = 'hello';
print("&moo=$moo");
?>

when put the url into a brower, &moo=hello comes up. which is correct according to all research i've done.

now this is what i have in flash:
myData = new LoadVars();
myData.onLoad = function(){
trace(myData.moo);
}
myData.load("cgi-bin/test.php");

now, what traces is not correct. this is what comes out:
$moo");

?>

how do i get moo from php into flash?

Laguana
01-25-2005, 06:02 AM
I've found that when you're using variables in php strings, it's often best to split it up and add in the value of the variable manualy.

Instead of
print("&moo=$moo")

try
print("&moo=".$moo ."&")
or even
echo "&moo=" .$moo ."&"

Duffman
01-25-2005, 06:11 AM
hmm, no luck, this is what comes out then.".$moo ."

CyanBlue
01-25-2005, 12:08 PM
The first thing you need to do is to make sure that you have no error on your PHP file...
Open up that PHP file over the web browser and test it to see if you are getting some error or not... I think you do have an error... That's why you are seeing that stuff...

<?php
$moo = 'hello';
echo("&moo=" . $moo . "&");
?>


myData = new LoadVars();
myData.onLoad = function(ok)
{
if (ok)
{
trace(this.moo);
}
else
{
trace("Problem");
}
}
myData.load("cgi-bin/test.php");

freddycodes
01-25-2005, 07:50 PM
If you are testing using trace(), you are not parsing the php script through a web server, I assume this is located at localhost. You are testing inside of flash, you need to specify the full http path to the script in this case.

myData.load("http://localhost/cgi-bin/test.php");

Duffman
01-25-2005, 09:03 PM
ahh, sweet, that works now. thanks.

Duffman
01-25-2005, 10:18 PM
can i send arrays through php? i'm just geting &music=Array and flash is printing Array

CyanBlue
01-25-2005, 10:22 PM
Yeah... You can do that if you use Flash Remoting/AMFPHP... ;)

freddycodes
01-25-2005, 10:31 PM
Or PHPObject, or join the array by a delimiter in php and pass that in and split it back out in flash.

Duffman
01-26-2005, 02:47 AM
so i can only send strings... the problem is that some of the directorys/file names have &'s in them, and that screws the string up for some reason

CyanBlue
01-26-2005, 02:49 AM
Urlencode those special characters... ;)

Duffman
01-26-2005, 06:36 AM
Urlencode those special characters... ;)
awesome, thanks.

Duffman
01-26-2005, 07:21 PM
ok, i'm having a problem with sendAndLoad() now. here is my php:
<?php
$quack = $moo;
echo("&quack=$quack");
?>

here is my action script:
var sendData:LoadVars = new LoadVars();
sendData.moo = "hello";

var myData = new LoadVars();
myData.onLoad = function(){
dText.text = myData.quack;
}

button.onRelease = function(){
sendData.sendAndLoad("http://localhost/cgi-bin/test.php", myData, "POST");
}

what i am trying to do is to send my php script "moo". then i want the php script to take the contents of moo, and put them in quack. i try to read myData.quack in flash, and i get undefined. what am i doing wrong?

freddycodes
01-26-2005, 07:28 PM
You probably don't have register globals turned on in for your php settings. You need to access the variables correctly in the php script. Plus you have a parse error in the php script. Missing semicolon.

Search the forums for register globals.

<?php
$quack = $_POST['moo'];
echo("&quack=$quack");
?>

Duffman
01-26-2005, 07:32 PM
ahh, works now, thanks!