我不明白为什么这个请求不起作用。
$query ="UPDATE $this->tabdata SET ";
foreach ($this->dataedit as $key => $value) {
$query .= "".$key." = '".$value."', ";
}
$pat ="+-0*/";
$query .= $pat;
$query = str_replace(", ".$pat," ", $query) ;
$query .=" WHERE id = '$id' ";
echo $query;
$sql = mysql_query($query);
答案 0 :(得分:0)
$query ="UPDATE $this->tabdata SET ";
foreach ($this->dataedit as $key => $value) {
$query .= "".$key." = '".$value."', ";
}
$pat ="+-0*/";
$query .= $pat;
$query = str_replace(", ".$pat," ", $query) ;
$query .=" WHERE id = '{$id}' ";//modify'$id' to '{$id}',try again
echo $query;
$sql = mysql_query($query);
链接Strings's single quoted part
注意:与双引号和heredoc语法不同,特殊字符的变量和转义序列在单引号字符串中不会扩展。