2017-02-20 65 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