PDA

View Full Version : Discovering PHP variable in HTML page


lokki
11-11-2006, 12:31 AM
I have a PHP script that returns a string value after some function runs. That variable is typically a message that is echoed to the screen which gives the user success/fail information, and some details. I'm sending an object to the PHP script via objectName.sendAndLoad("url.php", receiverObject, "POST").

I've tried using the following


echo "myVariable=$importantVariable"


but can't get Flash to see the variable. It prints OK in the HTML, as expected, but I think Flash sees the result as a String rather than an object or container, e.g., to Flash it's just "myVariable=Whatever message the variable returns" as text.

How can I embed the results of the variable in a way that Flash can understand? If I look at receiverObject by itself, it's the entire rendered HTML page, including the above mentioned string.

Any help on this?

Cota
11-11-2006, 01:20 AM
echo "&myVariable=".$importantVariable


Flash will be looking for myVariable

Flash Gordon
11-11-2006, 01:46 AM
just as an addition, PHP can really be picky (not like Flash). You need to have a semicolon at the end of your code or it will cause errors if that is indeed the end of the line or function or whatever you are doing there.

lokki
11-11-2006, 04:01 AM
echo "&myVariable=".$importantVariable


:rolleyes: ... shoulda remembered that from v4. Thanks :D

I've been able to get the responses when they are HTML, but a few of them are in JS popups. Any idea how to get those? I'm sending the variable to a textfield, so the JS code baffles it. Would I have to figure a way to strip out the javascript:alert() part of the variable?

lokki
11-11-2006, 04:02 AM
just as an addition...

Thanks - that actually came up moments after I read your reply for another bit I'm working on. It's the piddly stuff that keeps killing me...

lokki
11-11-2006, 08:14 PM
More info...

When the return is an error of any sort, the receive object's value is undefined. I've tried using toString() and simply tracing the output, but no love.

Again, I know the return from an error is a javascript alert, and the form I'm working with is redrawn with some CSS styles for highlighting. I'll worry about the CSS later, but I'd really like to know how to receive the JS alerts. Maybe it's possible to pass them to getURL() so they behave like popups?