in reply to Re^2: Perl and Mysql Queries
in thread Perl and Mysql Queries
It's always a good idea (and good defensive programming) to check the results of things as you go. So, I'd write
The die statements will leave something informative in your log file, and will give you information about what's failing. And I'm also going to encourage you to addmy $dbh = DBI->connect('dbi:mysql:jobs_db', "Poster', 'Poster Password'); defined $dbh or die "Unable to connect to DB: " . $dbh->errstr; my $sth =$dbh->prepare("INSERT INTO jobs (JobID,EmployerID, EmployerName,Title,City,StateProvince,Description,Function, Sector,Country,Posted) Values(?,?,?,?,?,?,?,?,?,?,?)"); defined $sth or die "Unable to prepare insert: " . $dbh->errstr; $sth->execute($JobID,$EmployerID,$EmployerName,$Title,$City, $StateProvince,$Description,$Function,$Sector,$Country,$Posted) or die "Failed to execute insert: " . $dbh->errstr;
at the top of all of your scripts. Generally, your scripts should compile cleanly, and should not put any warnings in the error log. If there are warnings, fix them.use strict; use warnings;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Perl and Mysql Queries
by Milti (Beadle) on Jun 11, 2024 at 12:27 UTC | |
by hippo (Archbishop) on Jun 11, 2024 at 12:47 UTC | |
by Milti (Beadle) on Jun 11, 2024 at 15:08 UTC | |
by marto (Cardinal) on Jun 11, 2024 at 15:49 UTC | |
by Danny (Hermit) on Jun 11, 2024 at 15:23 UTC | |
by hippo (Archbishop) on Jun 11, 2024 at 15:35 UTC | |
by Milti (Beadle) on Jun 11, 2024 at 15:56 UTC | |
by marto (Cardinal) on Jun 11, 2024 at 16:03 UTC | |
by talexb (Chancellor) on Jun 11, 2024 at 13:14 UTC | |
by talexb (Chancellor) on Jun 14, 2024 at 14:06 UTC | |
by soonix (Canon) on Jun 11, 2024 at 12:52 UTC | |
by Danny (Hermit) on Jun 11, 2024 at 14:21 UTC |
In Section
Seekers of Perl Wisdom