Tuesday, 15 July 2014

PHP/MySQL Cannot INSERT INTO -



PHP/MySQL Cannot INSERT INTO -

i'm facing quite unusual problem, error i've never saw before.

this code:

<?php funcion addpref($nome, $uid, $valore){ $sql = "insert preferenze_utenti (idpreferenza, idutente, value) values ((select id preferenze nome = ?), ?, ?)"; $stmt = $globals["db"]->prepare($sql); $stmt->bind_param('sis', $nome, $uid, $valore); homecoming $stmt->execute() ? true : false; } ?>

i'm using function this:

addpref("css_animations", 530, "true");

mind "true" string, because table take multiple types of info it, i'm using this.

the problem function returns true, , no new db record it. i've tried running query straight in phpmyadmin , works perfectly. i've noticed got warning mysql:

truncated wrong double value: 'css_animations '

where 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;

do not utilize values when utilize select on here:

$sql = "insert preferenze_utenti (idpreferenza, idutente, value) values ((select id preferenze nome = ?), ?, ?)";

change to:

$sql = "insert preferenze_utenti (idpreferenza, idutente, value) ((select id preferenze nome = ?), ?, ?)";

php mysql sql-insert

No comments:

Post a Comment