I have encountered this problem when doing an INSERT in MySQL. I receive the data from a form that the user completes (it is a textarea to leave comments in the news). In this form I have several buttons enabled to post videos or tweets, and it is in this last case that I am failing.
INSERT I do it this way:
$statement = $conexion->prepare("INSERT INTO comentarios (tipologia, texto,texto_sin_etiquetas, quien_comenta, en_que_hilo) VALUES (
'noticia',
'$comentario',
'$comentario_plano',
'$quien_comenta',
'$id_noticia'
)");
$statement->execute();
Operation is correct except when adding any tweets. In that case, it returns the following error:
SQLSTATE [HY093]: Invalid parameter number: no parameters were bound in C: \ xampp \ htdocs \ project \ news.php on line 106
I've checked a few times that all the variables when a tweet is added are correct, and that's the way it is.
If I try to publish a comment without including a tweet, and then I edit it to include one, it is updated without any problem.
I've gotten it to work for me this way:
$statement = $conexion->prepare("UPDATE comentarios SET texto = :texto, texto_sin_etiquetas = :texto_sin_etiquetas, fecha_edicion = :fecha_edicion, editado_por = :editado_por, veces_editado = veces_editado + 1 WHERE ID = :ID");
$statement->execute(array(
":texto" => $comentario,
":texto_sin_etiquetas" => $comentario_plano,
":fecha_edicion" => $fecha_total_actual,
":editado_por" => $usuario['gamertag'],
":ID" => $id_comentario
));