here is my update function inside my DB.PHP class and calling it from index below. can anyone see a mistake? I;m not showing any syntax error, no warnings, nothing. it jsut doesnt’ want to work?
Webmachine might have found the problem.
When you’re debugging a query, it’s a good idea to echo out the $sql and check if the query turned out the way you intended. And to copy and paste it in PHPMyAdmin (or whatever DBM you’re using) and see if it does what you want it to do.
no, field names should be replacing {$name}. that’s what I don’t get???
I tried to kill the script before $sql and I am getting {$name}= ? as a result on the page.
it should read → password = ? (I removed all other fields for simplicity of testing)
public function update($table, $id, $fields){
$set = '';
$x=1;
foreach($fields as $name => $value){
$set .= "{name} = ?";
if($x < count($fields)){
$set .=', ';
}
$x++;
}
die($set);
$sql="UPDATE {$table} SET {$set} WHERE id={$id}";
echo $sql;
if(!$this->query($sql, $fields)->error()){
return true;
}
return false;
}
is the script I use to call the function. I have a similar script for “inserting” and it works perfectly. so I know the DB::getInstance() function works perfectly.
you gotta be kidding me!!! Danmmmmmmmm. It’s as dumb as forgeting a semi colon at the end of the line and working and re-working the code and not seeing it.
someone come please and kick me on the chin lol…
Thank you fretburner… I don’t even have to test it, I can see that it was the problem. lol.