monks,
I am having a weird problem with a
$sth->execute problem! It is supposed to execute an SQL
INSERT statement. It works ok on my machine but once I put it onto the server it throws this error:
DBD::mysql::st execute failed: called with 1 bind variables when 0 are
+ needed at /cgi-bin/insert.pl line 44.
,at the same time i have the data inserted into the DB fine.I'm sure this isnt a bug just dont know how to get rid off!
This is the code:
my $street = "http://www.streetmap.co.uk/streetmap.dll?postcode
+2map?$zip&$zip";
#server vars and connection to the server
+
my $server = 'localhost';
my $db = 'somedb';
my $username= 'someusr';
my $password= 'somepass';
my $dbh =DBI->connect("dbi:mysql:$db:$server", $username, $password
+,{RaiseError =>1});
#SQL statement
my $SQL1 = "INSERT INTO property (address_1, address_2, county, cit
+y, zip, description, status, bedroom, map) VALUES ('$address_1', '$ad
+dress_2', '$county', '$city', '$zip', '$description', '$status','$bed
+room',?)";
my $SQL2 = "INSERT INTO picture (property_id,url) VALUES ('property
+_id'='pic_id','$file')";
#Prepare/execute and disconnect from db
foreach my $sql ($SQL1,$SQL2) {
my $sth = $dbh->prepare($sql) or die $dbh->errstr;
$sth->execute($street) or die $dbh->errstr;
}
$dbh->disconnect;
any help will do!Thanks
r_mehmed
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.