i want to update my database table newlessontime by posting a value from as3.but query is not working ...but when i give $etime = 4 in php code then database is updating lesson1 column but but when it comes for post method, value is not inserting into lesson1 column why is this happening? stdroll column value was inserted already i want to update lesson1 in same row of the table here is my php file
我想通过发布as3的值来更新我的数据库表newlessontime但是查询不起作用...但是当我在PHP代码中给出$ etime = 4时,数据库正在更新lesson1列,但是当它来到post方法时,值没有插入第1课,为什么会发生这种情况?已插入stdroll列值我想在表格的同一行更新lesson1这里是我的php文件
// lesson1t.php
include('connect.php');
$etime = $_POST['time1'];
//$etime = 4;
if (mysqli_query($link, "UPDATE newlessontime set lesson1=$etime WHERE stdroll=123")) {
echo 'result=System Updated';
} else {
echo 'result=error';
}
mysqli_close($link);
?>
here is the fla file
这是fla文件
home_Btn.buttonMode = true;
home_Btn.addEventListener(MouseEvent.CLICK, indexBtn_click1);
function indexBtn_click1(event:MouseEvent):void
{
myTime.stop();
variables.time1 = my_time.text ;
var request:URLRequest = new URLRequest('http://localhost/lesson1t.php');
request.method = URLRequestMethod.POST;
request.data = variables;
var loader:URLLoader = new URLLoader(request);
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.load(request);
loader.addEventListener(Event.COMPLETE, dataOnLoadl);
function dataOnLoadl(event:Event)
{
var variables:URLVariables = URLVariables(event.target.data);
trace(variables.result); // gives : System Updated
}
gotoAndPlay("manu");
SoundMixer.stopAll();
}
2 个解决方案
#1
Maybe you problem is that you do not defined variable.time1 as a var in as3.
也许你的问题是你没有将variable.time1定义为as3中的var。
Try this...
home_Btn.buttonMode = true;
home_Btn.addEventListener(MouseEvent.CLICK, indexBtn_click1);
function indexBtn_click1(event:MouseEvent):void
{
myTime.stop();
var request:URLRequest = new URLRequest('http://localhost/lesson1t.php');
request.method = URLRequestMethod.POST;
//You should define what is variables...
var variables:URLVariables = new URLVariables(); //this you forgot!
variables.time1 = my_time.text ;
request.data = variables;
var loader:URLLoader = new URLLoader(request);
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.load(request);
loader.addEventListener(Event.COMPLETE, dataOnLoadl);
function dataOnLoadl(event:Event)
{
var variables:URLVariables = URLVariables(event.target.data);
trace(variables.result); // gives : System Updated
}
gotoAndPlay("manu");
SoundMixer.stopAll();
}
Try this and tell us what happen...
试试这个并告诉我们发生了什么......
#2
I forgot to give quote around $etime
.
It should be '$etime'
..Now its working
我忘了在$ etime周围报价。它应该是'$ etime'..现在它的工作
#1
Maybe you problem is that you do not defined variable.time1 as a var in as3.
也许你的问题是你没有将variable.time1定义为as3中的var。
Try this...
home_Btn.buttonMode = true;
home_Btn.addEventListener(MouseEvent.CLICK, indexBtn_click1);
function indexBtn_click1(event:MouseEvent):void
{
myTime.stop();
var request:URLRequest = new URLRequest('http://localhost/lesson1t.php');
request.method = URLRequestMethod.POST;
//You should define what is variables...
var variables:URLVariables = new URLVariables(); //this you forgot!
variables.time1 = my_time.text ;
request.data = variables;
var loader:URLLoader = new URLLoader(request);
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.load(request);
loader.addEventListener(Event.COMPLETE, dataOnLoadl);
function dataOnLoadl(event:Event)
{
var variables:URLVariables = URLVariables(event.target.data);
trace(variables.result); // gives : System Updated
}
gotoAndPlay("manu");
SoundMixer.stopAll();
}
Try this and tell us what happen...
试试这个并告诉我们发生了什么......
#2
I forgot to give quote around $etime
.
It should be '$etime'
..Now its working
我忘了在$ etime周围报价。它应该是'$ etime'..现在它的工作