use DBI();
What is causing this insert to fail to err 1, the SELECT call works OK so its not credential issue.
$dbh = DBI->connect("DBI:mysql:$dbname:$dbhost","$dbuser","$dbpass");
my $sth = $dbh->prepare( "INSERT INTO call_fields VALUES ( ?, ?, ?, ? )" ) or die print "$DBI:errstr";
$sth->execute( "NULL", 0, 0, "testing" ) or die print "er $DBI::errstr";
mysql ver 5.5
This is perl 5, version 14, subversion 1 (v5.14.1) built for MSWin32-x64
NOTE: This syntax works OK:
$dbh->do(q/insert into call_fields values(null,0,0,”testing”) /) or die “$dbh::errstr”;
In the hope that you’re just a little confused trying to collate all the information that you’ve been given, here is your code rewritten to use all of the suggestions you’ve been given (along with a couple of other changes that I’ve made).
I’ve commented the changes I’ve made on each line.
I suspect it’s the removal of the unnecessary
printcalls and switching “NULL” toundefthat actually fix your problem.In addition, I’d strongly recommend a) setting the
RaiseErrorflag when connecting to the DB and b) adding the column names to the INSERT statement and then removing the first, nullable, column from the statement completely.