I have a problem with a prepared UPDATE statement, everywhere, the questions viewed here, and the syntax seems correct, what am I missing?
$update_page = $db->stmt_init();
$update_page = $db->prepare ("
UPDATE pages
SET page_title = ?, meta_description = ?, meta_keywords = ?, $content = ?
WHERE page_uri = ?
");
$update_page->bind_param('sssss', $page_title, $meta_description, $meta_keywords, $content, $page_uri);
$update_page->execute();
It throws me
Fatal error: call of bind_param () member function for non-object
referring to line 4 (one above the last line).
@Gaurav: here is the full code - on this page there is a SELECT and UPDATE statement, SELECT works:
if (!isset($page_uri))
{
$page_uri = 'home';
}
if (isset($_POST['update']))
{
$page_title = htmlspecialchars($_POST['page_title']);
$meta_description = htmlspecialchars($_POST['meta_description']);
$meta_keywords = htmlspecialchars($_POST['meta_keywords']);
$content = htmlspecialchars($_POST['content']);
$update_page = $db->stmt_init();
$update_page->prepare ("
UPDATE pages
SET page_title = ?, meta_description = ?, meta_keywords = ?, $content = ?
WHERE page_uri = ?
");
$update_page->bind_param('sssss', $page_title, $meta_description, $meta_keywords, $content, $page_uri);
$update_page->execute();
}
$select_page = $db->stmt_init();
$select_page = $db->prepare ("
SELECT page_id, page_title, meta_description, meta_keywords, content, sidebar
FROM pages
WHERE page_uri = ?
LIMIT 1
");
$select_page->bind_param('s', $page_uri);
$select_page->execute();
$select_page->bind_result($page_id, $page_title, $meta_description, $meta_keywords, $content, $sidebar);
$select_page->fetch();
$page_title = htmlspecialchars_decode($page_title, ENT_QUOTES);
$meta_description = htmlspecialchars_decode($meta_description, ENT_QUOTES);
$meta_keywords = htmlspecialchars_decode($meta_keywords, ENT_QUOTES);
$content = htmlspecialchars_decode($content, ENT_QUOTES);