我一直在研究这种将 AS3 和 mySQL 连接起来的 PHP 编码......
我遇到了这个错误,我无法弄清楚这是怎么回事......如果有人可以帮助第二双眼睛,我会非常感激......
这是 PHP 的更新编码
<?php
if(isset($_POST['userFirstName']) && isset($_POST['userLastName']) && isset($_POST['userEmail']) && isset($_POST['userNumber']) && isset($_POST['userMsg']))
{
$userFirstName=strip_tags($_POST['userFirstName']);
$userLastName=strip_tags($_POST['userLastName']);
$userEmail=strip_tags($_POST['userEmail']);
$userNumber=strip_tags($_POST['userNumber']);
$userMsg=strip_tags($_POST['userMsg']);
// connect with database.
$username="root";
$password="dp10aap";
$database="b-elite-fitness";
mysql_connect("localhost","$username","$password") or die (mysql_error());
mysql_select_db("$database") or die (mysql_error());
//query for inserting data in database.
$query="INSERT INTO 'formdp' VALUES('NULL','".mysql_real_escape_string($userFirstName)."','".mysql_real_escape_string($userLastName)."','".mysql_real_escape_string($userEmail)."','".mysql_real_escape_string($userNumber)."','".mysql_real_escape_string($userMsg)."')";
if($query_run=mysql_query($query))
{
echo'Data inserted.';
} else {
die(mysql_error());
}
}
?>
这是我的 AS3 编码....
processing_mc.visible = false;
function checkComplete(evt:MouseEvent):void {
// Create A new URLVariables instance to store the variable
var phpVars:URLVariables = new URLVariables();
// Create a variable (e.g. candidate) to send
phpVars.userFirstName = firstname_txt.text;
phpVars.userLastName = lastname_txt.text;
phpVars.userNumber = number_txt.text;
phpVars.userEmail = email_txt.text;
phpVars.userMsg = msg_txt.text;
// Create a new URLRequest instance sending data to "ascom01.php"
var myRequest:URLRequest = new URLRequest("form.php");
// Send data using the POST method
myRequest.method = URLRequestMethod.POST;
var loader:URLLoader = new URLLoader();
loader.load(myRequest);
loader.addEventListener(Event.COMPLETE, response);
function response(e:Event):void
{
trace(loader.data);
}
if(!firstname_txt.length) {
status_txt.text = "Please enter your first name";
} else if(!lastname_txt.length) {
status_txt.text = "Please enter your last name";
} else if (!email_txt.length) {
status_txt.text = "Please enter your email";
} else if (!number_txt.length) {
status_txt.text = "Please enter your phone number";
} else {
}
}
// handler for the PHP script completion and return of status
function completeHandler(event:Event):void {
processing_mc.visible = false;
firstname_txt.text = "";
lastname_txt.text = "";
email_txt.text = "";
number_txt.text = "";
msg_txt.text = "";
status_txt.text = event.target.data.return_msg;
}
// Add event listener for submit button click
submit_btn.addEventListener(MouseEvent.CLICK, checkComplete);
我遇到的问题是,一旦我点击发送按钮,数据将不会发送......有什么想法吗?