PHP - Prepared statements error, what's wrong?

Jerrree

New Member
So here's the codeblock:\[code\] $query = "UPDATE users SET ?=? WHERE ?=?"; $type = "s"; $type .= substr(gettype($valname), 0, 1); $type .= 'i'; if ( $smtp = $this->conn->prepare($query) ) { $smtp->bind_param($type, $colname, $valname, 'id', 40); $smtp->execute(); $smtp->close(); }else { return $this->conn->error; }\[/code\]For some reason it refuses to bind the parameters, and it gives me this error: 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 '?=? WHERE ?=?' at line 1If i add backticks ( ` ) or singlequotes ( ' ) around the questionmarks i get this error instead:Unknown column '?' in 'where clause'Any ideas what's gone wrong? I've been sitting here for hours playing with it, god it's frustrating!!Thanks a bunch!
 
Back
Top