I'm trying to update a flash movie quiz that records names and question answers - I did not write the original application. The quiz works, except that it replaces the name with null when recording data. All the other records work fine. I have deleted out the res2 - res12
just to shorten it up, they all work well.
- Im using Flash Pro CS6
- The code is in AS3
Thanks in advance for any light you can shed on this.
From Name input page of the quiz. participname
is the text field input:
stop();
btn1.addEventListener(MouseEvent.MOUSE_UP,function():void {
var Name:String=participname.text.toString();
gotoAndPlay(3);
});
From the last page of the quiz
sendData(); function sendData(){ var messages:URLRequest = new URLRequest("./insertresult.php") messages.method = URLRequestMethod.POST
var posts:URLVariables = new URLVariables()
posts.Name = Name
posts.DateCurrent = dtFormatted
posts.Res01 = res01
messages.data = posts
trace(posts);
var loader:URLLoader = new URLLoader()
loader.dataFormat = URLLoaderDataFormat.TEXT
// loader.addEventListener(Event.COMPLETE, dataOnLoad)
loader.load(messages)
trace(messages);
From the insertresult.php:
<?php
//Capture data from $_POST array
$name = $_POST['Name'];
$date = $_POST['DateCurrent'];
$res1 = $_POST['Res01'];
/* if(!$name ) {
echo "no input using default values <br>";
$name = 'deleteme';
}*/
$connect = mysql_connect("mydatabase");
mysql_select_db ("PAlogindatabase", $connect);
$result = mysql_query("INSERT into rhymeoddity1 (name,date,res1) values ('$name','$date','$res1')");
if($result) echo "writing=Ok&";
else echo "writing=Error";
?>
mysql_*
functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial. – h2ooooooo