help in establishing connection to php and mysql data base.
Hi,
i have been trying to execute a simple flash program that communicates with a php page which is linked to a mysql database.
somehow the php is not returning any data to flash , and even falsh is not sending any data to php.. I am using wamp server on win7.
Heres my actionscript code:
stop();
var variables:URLVariables = new URLVariables();
var varSend:URLRequest = new URLRequest("php.php");
varSend.method = URLRequestMethod.POST;
varSend.data = variables;
var varLoader:URLLoader = new URLLoader;
//varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
varLoader.dataFormat = URLLoaderDataFormat.TEXT;
varLoader.addEventListener(Event.COMPLETE, completeHandler);
variables.requestCode = "homepage";
//variables.myRequest="homepage";
trace(variables);
varLoader.load(varSend);
function completeHandler(event:Event):void
{
trace(event.target.data.t_passed);
var t_recieved = event.target.data.t_passed;
//t_txt.text = "t_passed";
t_txt.text=t_recieved;
}
try
{
varLoader.load(varSend);
}
catch (error:Error)
{
trace("error");
}
And this is my php code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<?php
//error_reporting(E_ALL & ~E_NOTICE);
$connection=mysql_connect("localhost" , "root" , "");
if(!$connection)
{
die("failed".mysql_error());
}
$db_select = mysql_select_db("questions",$connection);
if (!$db_select)
{
die("failed".mysql_error());
}
if ($_POST['requestCode'] == "homepage") {
$pageName = $_POST['requestCode'];
echo ($_POST['requestCode']);
}
$result=mysql_query("select q from quest where qno=111",$connection);
while($row=mysql_fetch_array($result))
$t=$row[0];
//print "t_passed = $s";
echo "t_passed=".$t;
mysql_close($connection);
?>
</head>
<body>
</body>
</html>
The php gives me Undifined notice for the 'requestCode' variable...
please help..
Thanks in advance