Tengo un problema con la declaración preparada de ACTUALIZACIÓN, busqué en todas partes, examiné las preguntas aquí y la sintaxis parece ser la correcta, ¿qué me estoy perdiendo?Problema con la declaración preparada de ACTUALIZACIÓN en PHP
$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();
Esto me tiros
Fatal error: Call to a member function bind_param() on a non-object
refiriéndose a la línea 4 (una encima de la última línea).
@Gaurav: aquí está el código completo - Tengo en esta página tanto instrucción SELECT y UPDATE, obras SELECT:
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);
¿Qué muestra tu phpinfo() en caso de mysqli? – egis
por cierto, muestre el código donde inicia el objeto $ db. Puede ser que no se haya seleccionado ninguna base de datos;) – egis
@egis - este es el código completo: $ db = new mysqli (DBHOST, DBUSER, DBPASS, DATABASE); - Acerca de phpinfo(), ¿qué debo buscar, tengo instalado mysqli, sé que, de hecho, hay algo más que cuidar? – CodeVirtuoso