Hello everybody, I am new to Flash and PHP and I need a little help. Wonderful guys like you are making it possible for newbies like me to enjoy programming. Please help. Thanks.
I am trying to pass a text value from flash to php which would be picked up by an SQL query to select all from a table where book_id is equal to the variable value I have passed from Flash. The result would then be displayed via xml to flash. It works all right when I dont put a constraint and just select all but I need to select particular news items so that readers of a news item can view comments for the particular story.I have used all the tricks that I know but i still get undefined in my result. Could u please explain why?
Here are the codes please.
//Flash
on(release){
gotoAndStop(2);
contactVars=new LoadVars();
contactVars.theId=ivalue.text;
ontactVars.onLoad=function(ok){
if(ok){
//
}else{
//
}
}
contactVars.sendAndLoad('comments.php',contactVars,'POST');
}
//PHP
<?PHP
$id=$_POST['theId'];
$link = mysql_connect("mysql","pojobauk","sakayayA");
mysql_select_db("newsdatabase");
$query= "SELECT * FROM comments WHERE book_id='$id' ORDER BY comment_id DESC";
$results = mysql_query($query);
echo "<?xml version=\"1.0\"?>\n";
echo "<comments>\n";
while($line = mysql_fetch_assoc($results)) {
echo"<group>\n";
echo "<name>" . $line["name"] . "</name>\n";
echo "<subject>" . $line["subject"] . "</subject>\n";
echo "<comment>" . $line["comment"] . "</comment>\n";
echo"</group>\n";
}
echo "</comments>\n";
//mysql_close($link);
?>
As I said I only get undefined error message on display in flash. Thanks in advance.