PDA

View Full Version : variables problem in onLoad-function


veroo
08-01-2007, 08:09 PM
Hi,

I have this problem, hopefully you can help:

(I made test.fla and test.php to illustrate the problem)

test.fla=

function loadEntries() {
// Show Please wait text
txtMessages.text = "Loading entries... Please wait...";
// Begin Loading
var ontvang:LoadVars = new LoadVars();
ontvang.load("test.php");
ontvang.onLoad = function(){
txtMessages.htmlText = ontvang.naam;
//of
this.naam txtMessages2.htmlText = ontvang.email;
//of
this.email
}
}
loadEntries();
stop();


test.php=

$DBhost = "localhost";
// Database Server
$DBuser = "test";
// Database User
$DBpass = "test";
// Database Pass
$DBName = "test";
// Database Name
$table = "test";
// Database Table

// Connect to mySQL Server
$DBConn = mysql_connect($DBhost,$DBuser,$DBpass) or die("Error in GuestBook Application: " .
mysql_error());
// Select mySQL Database
mysql_select_db($DBName, $DBConn) or die("Error in GuestBook Application: " . mysql_error());


$sql = "SELECT * FROM test WHERE ID = 1";
$rs = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
$row = mysql_fetch_assoc($rs);
$name = $row['name'];
$email = $row['email'];
echo('&naam=' . $name . '&email=' . $email . '&');


The output in the textfields (defined in flash) return:

' . $name . '
' . $email . '

I've tried everything (no quotes for $name and $email, single quotes, dubble quotes, ...). If I replace these variables by a string, f.e.

echo('&naam=test&email=test');

it does work! Any clue someone?

Thanks!

sneakyimp
08-02-2007, 06:09 PM
have you tried viewing test.php in a browser? If you try and you just see the source code, it means your server isn't parsing the file as php.

your actionscript also looks broken...esp. this line:
this.naam txtMessages2.htmlText = ontvang.email;

veroo
08-03-2007, 10:52 AM
Hi,

Viewing test.php in a browser gives the correct
result. Thanks! ;)

My actionscript-code wasn't broken. The code text.naam
is comment which accidently was placed on a next
line.

sneakyimp
08-03-2007, 07:59 PM
so it's working then?

veroo
08-08-2007, 10:40 AM
Yep it does!! Thanks a lot