0

I don't understand why this request doesn't work.

$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);
Skatox
  • 4,237
  • 12
  • 42
  • 47

1 Answers1

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);

link Strings's single quoted part

Note: Unlike the double-quoted and heredoc syntaxes, variables and escape sequences for special characters will not be expanded when they occur in single quoted strings.

Liuqing Hu
  • 1,970
  • 3
  • 11
  • 15
  • 3
    please, *please*, dont copy paste other answers. http://stackoverflow.com/a/22851507/953684 you even having variable names from that other answer copied here. – Sharky Apr 04 '14 at 04:35
  • @Sharky so sorry,that i answer the same question http://stackoverflow.com/a/22826690/1969039 .but linked wrong to others answer – Liuqing Hu Apr 04 '14 at 05:03