mysql显示执行成功,但数据不更新
publicfunctionsetUserScore($accountid){$sql="SELECT*FROMuserswhereuserid=".$accountid...
public function setUserScore($accountid)
{
$sql = "SELECT * FROM users where userid=".$accountid;
$res = mysql_query($sql,$this->link);
$row2 = mysql_fetch_assoc($res);
$ore =$row2['ore'];
$shi=$row2['shi'];
$jiangli=500;
$intkdhjf=$row2['jscore'];
if ($intkdhjf<10 )
{
$response= array('error'=>"1",'data'=>"积分小于10,不能兑换!");
}
else
{
$intmoshu=$intkdhjf % 10;
$intjf=floor($intkdhjf *0.3);
$jj=$intjf;
if ($intmoshu==0)
{
$intms=0;
}else{
$intms=$intkdhjf-10*floor($intkdhjf /10);
}
$sql1 = "update users set score=score+$jj where userid=$this->userid;";
$sql2 = "update users set jscore=$intms where userid=$accountid";
if(mysql_query($sql1,$this->link) && mysql_query($sql2,$this->link))
{
$response= array('error'=>"0",'data'=>$intms);
}else{
$response=array('error'=>"2",'data'=>"兑换失败");
}
}
return $response;
}
测试发现$sql1不能正常执行,sql可以正常执行,请高手帮我看看是怎么回事 展开
{
$sql = "SELECT * FROM users where userid=".$accountid;
$res = mysql_query($sql,$this->link);
$row2 = mysql_fetch_assoc($res);
$ore =$row2['ore'];
$shi=$row2['shi'];
$jiangli=500;
$intkdhjf=$row2['jscore'];
if ($intkdhjf<10 )
{
$response= array('error'=>"1",'data'=>"积分小于10,不能兑换!");
}
else
{
$intmoshu=$intkdhjf % 10;
$intjf=floor($intkdhjf *0.3);
$jj=$intjf;
if ($intmoshu==0)
{
$intms=0;
}else{
$intms=$intkdhjf-10*floor($intkdhjf /10);
}
$sql1 = "update users set score=score+$jj where userid=$this->userid;";
$sql2 = "update users set jscore=$intms where userid=$accountid";
if(mysql_query($sql1,$this->link) && mysql_query($sql2,$this->link))
{
$response= array('error'=>"0",'data'=>$intms);
}else{
$response=array('error'=>"2",'data'=>"兑换失败");
}
}
return $response;
}
测试发现$sql1不能正常执行,sql可以正常执行,请高手帮我看看是怎么回事 展开
2013-06-01
展开全部
$sql1 = "update users set score=score+$jj where userid=$this->userid;";
sql语句里有分号
sql语句里有分号
更多追问追答
追问
有分号了,目前是有时候执行成功,有时候执行不成功
追答
Description
resource mysql_query
( string $query
[, resource $link_identifier = NULL
] )
mysql_query() sends a unique query (multiple queries
are not supported) to the currently
active database on the server that's associated with the
specified link_identifier.
An SQL query
The query string should not end with a semicolon.
Data inside the query should be properly escaped.
PHP的官方说明,你的SQL1里最后有个分号,不是PHP语句
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询