Put your query with quotes:
$query = "INSERT INTO historial(`titulo_his`, `autor_his`, `editorial_his`, `isbn_his`, `color_his`, `fecha_inicio_his`, `fecha_final_his`, `idusuarios_his`, `codlibros_his`)
VALUES('{$tit}', '{$aut}', '{$edit}', '{$isbn}', '{$color}', '{$fechaP}', '{$fecha}', '{$_SESSION['idusuarios']}', '{$libro}')";
The problem is that you are trying to insert strings without enclosing them into quotes, so the query will fail
PS: And don’t use mysql_* functions the extension is deprecated.
PS2: Backticks for field names are not required, but i like it 🙂
1
solved mysql reporting syntax error