my $hour_master_db = DBI->connect("DBI:mysql:database=$database;host=$ +host;mysql_socket=/opt/lampstack-5.5.27-0/mysql/tmp/mysql.sock","root +","", {'RaiseError' => 1}); my $hour_insert_sth = $hour_master_db->prepare("insert into esme_hourl +y_master values(?,?,?,?,?,?,?,?,?,now(),'MIS'"); $hour_insert_sth->execute($hr,$date,$system_id,$total_sub_data{$statsd +ate}{$system_id},$totalacpt_data{$statsdate}{$system_id},$total_rej_d +ata{$statsdate}{$system_id},$del_data{$statsdate}{$system_id},$undel_ +data{$statsdate}{$system_id},$exp_data{$statsdate}{$system_id}) or di +e $DBI::errstr;

This is the code I am using to insert data into mu DB. But its showing error

DBD::mysql::st execute failed: You have an error in your SQL syntax; +check the manual that corresponds to your MySQL server version for th +e right syntax to use near '' at line 1 at final.pl line 328. 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 '' at line 1 at final.pl line 328.
But when I print data its showing perfectly like  09,2015-11-03,uni_upe,499887,466649,33238,0,0,0 I think I have to add ' ' to uni_upe which is a string. But how can I?? Or is there any other mistake???

My DB schema

+---------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+-------------+------+-----+---------+-------+ | hour | int(2) | NO | PRI | NULL | | | day | date | NO | PRI | NULL | | | system_id | varchar(21) | NO | PRI | | | | submitted | bigint(20) | NO | | 0 | | | accepted | bigint(20) | NO | | 0 | | | rejected | bigint(20) | NO | | 0 | | | delivered | bigint(20) | NO | | 0 | | | undelivered | bigint(20) | NO | | 0 | | | expired | bigint(20) | NO | | 0 | | | creation_date | datetime | NO | | NULL | | | created_by | varchar(20) | NO | | | | +---------------+-------------+------+-----+---------+-------+ 11 rows in set (0.00 sec)


In reply to $hour_insert_sth->execute showing error by ravi45722

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.