我想在我的数据库中插入计时器时间。我已经创建了一个计时器类,它以小秒和秒为单位(在动态文本字段中).i有一个home_button我希望当我点击home_button计时器的时候会插入进入得分表的时间列。所有代码都工作正常。列正在更新但是时间没有出现在数据库表中请帮我解决这个问题..还有我的as3代码
var myCount:Number = 00;
var seconds:Number = 00;
var minutes:Number = 0;
var myTime:Timer = new Timer(1000,myCount);
myTime.addEventListener(TimerEvent.TIMER, startCount);
my_time.text = "";
myTime.start();
function startCount(event:TimerEvent):void
{
seconds +=1;
if (seconds > 60)
{
seconds =00;
minutes +=1;
}
my_time.text = minutes+":"+(seconds >= 10 ? seconds : "0"+seconds);
}
var variables:URLVariables = new URLVariables();
variables.time1 = my_time.text;
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/timesend.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, dataOnLoad);
}
function dataOnLoad(event:Event)
{
var variables:URLVariables = URLVariables(event.target.data);
trace(variables.result); // gives : System Updated
}
这里是timesend.php
<?php
// data.php
include('connect1.php');
// if we are here, that's mean that we are already connected to mysql server
// and we don't need to do another connection
$etime = $_POST['time1'];
// $link is the same connection created in your connect.php script
if (mysqli_query($link, "INSERT INTO scoreu (user) VALUES('$etime')")) {
echo 'result=System Updated';
} else {
echo 'result=error';
}
mysqli_close($link);
&GT;
答案 0 :(得分:0)
表字段类型声明中有一个问题..i声明它为varchar ..但现在我已经将类型修改为TEXT ..现在它工作正常..