I'm facing a quite strange problem, with an error I've never saw before.
This is my code:
<?php
funcion addPref($nome, $uid, $valore){
$SQL = "INSERT INTO preferenze_utenti (idPreferenza, idUtente, value)
VALUES ((SELECT id FROM preferenze WHERE nome = ?), ?, ?)";
$stmt = $GLOBALS["db"]->prepare($SQL);
$stmt->bind_param('sis', $nome, $uid, $valore);
return $stmt->execute() ? true : false;
}
?>
I'm using the function like this:
addPref("css_animations", 530, "true");
Mind that "true" is a string, because this table accept multiple types of data into it, so I'm just using it like this.
The problem is that actually the function returns always true, and I get no new db record for it. I've tried running the query directly in PHPMyAdmin and works perfectly. I've noticed that i got this warning from MySQL:
Truncated incorrect DOUBLE value: 'css_animations '
Where am I going wrong?
Tables:
CREATE TABLE IF NOT EXISTS `preferenze_utenti` (
`idPreferenza` bigint(20) NOT NULL,
`idUtente` bigint(20) NOT NULL,
`value` varchar(256) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `preferenze` (
`id` bigint(20) NOT NULL,
`nome` char(64) NOT NULL,
`def` varchar(128) NOT NULL COMMENT 'Valore default'
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
nomeinpreferenze?