Fatal error: Call to a member function escape() on a non-object in
I'm trying to update my queries, but I stumble upon the same error again and again...
Fatal error: Call to a member function escape() on a non-object in ...
This is my function:
//update activity
public function updateActivity($db, $id) {
$sql = "UPDATE tblLeidingAgenda SET
datum = '".$db->escape($this->datum)."',
uur = '".$db->escape($this->uur)."',
titel = '".$db->escape($this->titel)."',
uitleg = '".$db->escape($this->uitleg)."',
link = '".$db->escape($this->link)."',
aanwezig = '".$db->escape($this->aanwezig)."',
auteur = '".$db->escape($this->auteur)."'
WHERE id = '".$id."'";
r开发者_开发技巧eturn $db->insert($sql);
}
And this is my code:
if (empty($_POST['up_datum']) || empty($_POST['up_uur']) || empty($_POST['up_titel']) || empty($_POST['up_uitleg'])) {
$error = 'no input';
} else {
$datecorrect=date('Y-m-d',strtotime($_POST['up_datum']));
$agenda = new Leidingsactiviteit();
$agenda->datum = $datecorrect;
$agenda->uur = $_POST['up_uur'];
$agenda->titel = $_POST['up_titel'];
$agenda->uitleg = $_POST['up_uitleg'];
$agenda->auteur = $_SESSION['user']['naam'];
if ($agenda->updateActivity($_DB,$_POST['id'])) {
$feedback = 'ok';
$bericht = 'test';
mail('me@gmail.com', 'Update: '.$agenda->titel, $bericht);
}
else {
$feedback = 'not ok';
}
}
EDIT $_DB
declared...
define('MYSQL_HOST', '***');
define('MYSQL_DB', '***');
define('MYSQL_USER', '***');
define('MYSQL_PASSW', '**');
// Initialize (global vars)
$_DB = new DBConnection(MYSQL_HOST, MYSQL_DB, MYSQL_USER, MYSQL_PASSW);
Where is the variable $_DB
declared? From what you have posted, it never gets declared so I don't know what is inside the object (if it is even an object by that point to begin with).
Try var_dump($_DB);
before the if ($agenda->updateActivity($_DB,$_POST['id']))
and post the results of that if you don't figure out your problem.
精彩评论