2017-02-20 62 views
0

谁能告诉我,为什么它不更新MySQL查询,其执行JavaScript,所有的工作,但它只是没有更新到表账户和行‘积极’的mysql_query(“更新......没有更新

的行值应为 '1'

任何人都可以修复它的感谢

<script> 
 
\t function positive(accid) 
 
\t { 
 
\t \t top.document.location.href = "myaccounts.php?job=positive&positive="+accid; 
 
\t } 
 
</script>  
 
<?php 
 
if(isset($_GET["job"]) && $_GET["job"] == "positive" && !empty($_GET["positive"])) 
 

 
\t { 
 
       $account_id = mysql_real_escape_string($_GET["account_id"]); 
 
       mysql_query("UPDATE `accounts` SET `positive`= '1' WHERE account_id = '$account_id'"); 
 

 

 
\t } 
 
?> 
 

 
<td class="formstyle"><div align="center" style="padding:5px;"> 
 
<img src="" width="35" height="35" style="cursor: pointer;" onclick="if(confirm(\'Confirm Positive Feedback ?\')) positive(\''.$row["account_id"].'\');" /></div> 
 
</td>

+0

在上一个问题中,您被告知要添加错误检查。你有没有尝试在这里做同样的事情? – Barmar

+0

没有即时尝试现在将现有数据更新到行中,但问题在这里 $ account_id = mysql_real_escape_string($ _ GET [“account_id”]); 它没有得到account_id当我手动尝试它的ID工作,你有什么想法吗? – JoeFixer

+0

当您查看HTML源代码时,您是否在'onclick'中看到了帐户ID? – Barmar

回答

-1

你的SQL语法错了,$ ACCOUNT_ID应该是连接在一起。

+0

他使用反引号,这是MySQL引用数据库和列名的方式。 – Barmar

+0

是的,我在点击时看到了account_id – JoeFixer