當我嘗試執行更新語句我得到了以下錯誤:Erreur:SQLSTATE [42000]:語法錯誤或訪問衝突:1064您的SQL語法錯誤;
Erreur : SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Issy-les-Moulineaux ' where ssiphone_idstation=46' at line 1
我的更新語句是:
$bdd->exec("update ssiphone_stationdeservice set $cle='$element' where ssiphone_idstation=$id");
這是在PHP代碼,THX在您的幫助:)
$ CLE和$元素都在陣,我的代碼是:
foreach($table1 as $cle => $element)
{
$bdd->exec("update ssiphone_stationdeservice set $cle='$element' where ssiphone_idstation=$id");
}
現在表1是包含我的表和它的值的列名的數組:
$table1=array();
$table1['ssiphone_etatstation']=$etat;
$table1['ssiphone_commerce']=$commerce;
$table1['ssiphone_stationdelavage']=$lavage;
$table1['ssiphone_typescarburants']=$lescarburants;
$table1['ssiphone_joursdelasemaine']=$jourssemaines;
$table1['ssiphone_horaires ']=$this->horaires;
$table1['ssiphone_telephone ']=$telephone;
$table1['ssiphone_sensdecirculation ']=$this->sensDeCirculation;
$table1['ssiphone_adresse ']=$this->adresse;
$table1['ssiphone_ville']=$this->ville;
$table1['ssiphone_departement']=$this->departement;
$table1['ssiphone_nomstation ']=$this->nomStation;
您是否爲'$ cle','$ element'和'$ id'設置了值? – 2011-03-18 14:17:17
沒有'$ cle','$ element'和'$ id'的值,很難說。我衷心希望你能夠非常全面地驗證這些輸入--SQL注入就在角落。 – Mat 2011-03-18 14:18:18
列名不能在其名稱中包含'-'標誌。您的查詢設計錯誤。 – Furicane 2011-03-18 14:20:41