in reply to Re: Error in $sth->execute()
in thread Error in $sth->execute()

I know the error where it is. And I mentioned that too.

Its from Module while executing in programm

DBD::mysql::st execute failed: You have an error in your SQL syntax; c +heck the manual that corresponds to your MySQL server version for the + right syntax to use near ''cat0=1,cat1=0,cat2=0,cat3=0,cat4=0,cat5=0 +,cat6=0,cat7=0'' at line 1 at ./dnd_category_management_incremental_p +rovisioning.pl line 208, <FD> line 1.

Its from DB terminal while I executing manually

mysql> insert into user_master (msisdn,cat0,cat1,cat2,cat3,cat4,cat5,c +at6,cat7,vip,SAcode,phone_type) values (919596354636,0,1,0,0,0,0,0,0, +0,0,0)on duplicate key update 'cat0=1,cat1=0,cat2=0,cat3=0,cat4=0,cat +5=0,cat6=0,cat7=0'; ERROR 1064 (42000): You have an error in your SQL syntax; check the ma +nual that corresponds to your MySQL server version for the right synt +ax to use near ''cat0=1,cat1=0,cat2=0,cat3=0,cat4=0,cat5=0,cat6=0,cat +7=0'' at line 1

If I remove the single quotes the query is executing properly.

Its very clear that when I passing argument to $sth->execute() its taking the argument and adding '' (single quotes) to the statement. If the single quotes is not there it will execute properly. Why the module adding single quotes to my query. How to make query without adding quotes

This code is working very fine

my $IP = "172.16.2.163"; my $user = "root"; my $table = "user_master"; my $dbh = DBI->connect("DBI:mysql:database=$db;host=$IP;mysql_socket=/ +opt/lampstack-5.5.27-0/mysql/tmp/mysql.sock","$user","",{'RaiseError' + => 1}); my $user_sth = $dbh->prepare("insert into user_master (msisdn,cat0,ca +t1,cat2,cat3,cat4,cat5,cat6,cat7,vip,SAcode,phone_type) values (?,?,? +,?,?,?,?,?,?,?,?,?) on duplicate key update cat0=0"); $user_sth->execute($msisdn,@db_values,0,$SAC,$phone_type) or die $DBI: +:errstr;
CREATE TABLE `user_master` ( `msisdn` bigint(20) NOT NULL, `cat0` tinyint(1) DEFAULT '0', `cat1` tinyint(1) DEFAULT '0', `cat2` tinyint(1) DEFAULT '0', `cat3` tinyint(1) DEFAULT '0', `cat4` tinyint(1) DEFAULT '0', `cat5` tinyint(1) DEFAULT '0', `cat6` tinyint(1) DEFAULT '0', `cat7` tinyint(1) DEFAULT '0', `vip` tinyint(1) DEFAULT '0', `SAcode` bigint(10) NOT NULL DEFAULT '0', `phone_type` bigint(10) NOT NULL DEFAULT '0', PRIMARY KEY (`msisdn`), KEY `num` (`msisdn`) )

But when I use "?" after duplicate key its not working

my $IP = "172.16.2.163"; my $user = "root"; my $table = "user_master"; my $dbh = DBI->connect("DBI:mysql:database=$db;host=$IP;mysql_socket=/ +opt/lampstack-5.5.27-0/mysql/tmp/mysql.sock","$user","",{'RaiseError' + => 1}); my $user_sth = $dbh->prepare("insert into user_master (msisdn,cat0,ca +t1,cat2,cat3,cat4,cat5,cat6,cat7,vip,SAcode,phone_type) values (?,?,? +,?,?,?,?,?,?,?,?,?) on duplicate key update ?"); $user_sth->execute($msisdn,@db_values,0,$SAC,$phone_type,$db_update_cm +d) or die $DBI::errstr;