当我尝试执行更新语句我得到了以下错误: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