2017-02-20 78 views
-2

任何人都可以告訴我爲什麼不插入數據庫?INSERT INTO ...錯誤不能插入

<?php 
 
if(isset($_GET["job"]) && $_GET["job"] == "positive" && !empty($_GET["positive"])) 
 
\t { 
 
      $query = mysql_query("INSERT INTO accounts (positive) values('1')") or die ("uploading error! Try diffrent base or contact dev!"); 
 
\t } 
 

 
?> 
 

 

 
<script> 
 
\t function positive(account) 
 
\t { 
 
\t \t top.document.location.href = "myaccounts.php?job=positive&positive="+account; 
 
\t } 
 
</script> 
 
<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>

我嘗試用添加的onclick功能的腳本其上有太多....請任何幫助IM stucked喜歡這裏12小時

+2

後以何種方式這裏會失敗? JavaScript代碼是否被執行?瀏覽器位置是否成功更改? PHP代碼是否執行?服務器的迴應是什麼?這裏具體發生了什麼? – David

+0

您確定要發送非空的'account'參數嗎? – Barmar

+0

你不會把'$ _GET [「positive」]'放到數據庫中,你總是放上'1'。 – Barmar

回答

-1

嘗試的DIE()末增加Mysql_error()說會給你更多的錯誤信息。

mysql_query("INSERT INTO accounts SET positive=\"".'1'."\"") or die ("uploading error! Try diffrent base or contact dev! ".mysql_error()); 

一種不顯示mysql_error();的方法,讓人們看到它。

EX:

function errorsignup($error,$details,$message) 
{ 
    if($message == "") 
    mysql_query("INSERT INTO er SET name=\"".$error."\",details=\"".$details."\"") or die("Error: ".mysql_error()); 
    else 
    { 
     mysql_query("INSERT INTO er SET name=\"".$error."\",details=\"".$details."\"") or die("Error: ".mysql_error()); 
     return $message; 
    } 
} 
function getRealIpAddr() 
{ 
    if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet 
    { 
     $ip=$_SERVER['HTTP_CLIENT_IP']; 
    } 
    elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy 
    { 
     $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; 
    } 
    else 
    { 
     $ip=$_SERVER['REMOTE_ADDR']; 
    } 
    return $ip; 
} 
function standarderror() 
{ 
    return "OH NO... An Error Has Occured<br />We Were Not Expecting This<br />An Error Message With Details Has Been Sent To Web Admin.<br /> You May Try One Of The Following<ul><li>Try Again</li><li>Or Return To Home Page Then Try Again</li><li>Wait 24 Hours And Try Again</li><li>If Error Persists Then Please Just Wait 24 Hours.</li></ul><br />Thanks For Your Support: Web Master/Administrator - Double J Computers"; 
} 

現在我們添加了錯誤消息每次mysql_query();

die(errorsignup('Error In Your Area: - SQL UPDATE edit - '.date('m-d-y').' - '.getRealIpAddr(),'SQL ERROR: '.mysql_error(),standarderror())); // this returns the standard error function so people have a few instructions to try again. 
//this also records the area like what page and what sql edit or update or w/e and the full error 
+0

仍然不能正常工作......如果我發現了一個錯誤,請檢查ISSET – JoeFixer

+0

它就像資產沒有執行我現在已經移除了資產同樣的東西只是令人耳目一新,而JavaScript將代碼放入眉毛 – JoeFixer

+0

謝謝它的工作yaaay – JoeFixer