Hi,Hi Gavin,
First, sorry for the wrap on the lines below, and my apologies if this message has been seen already- I appear to be having problems sending to nntp.perl.org (I didn't realise you had to be subscribed to [EMAIL PROTECTED] to send).
I am trying to insert some values into a mySQL database, all of the scalars below have a value(none are undefined). I keep getting errors similar to the one below and despite being instructed to read the mySQL manual, I cannot find anything that relates to the problem I'm experiencing.
Is the problem with my Perl (likely), or mySQL? Can anyone offer a solution or pointers towards possible solutions?
Thank you in advance for any help you may be able to provide.
CODE: my $dbh = DBI->connect("DBI:mysql:database","username","password"); my $result = $dbh->prepare("INSERT INTO table( sitename,siteurl,category,description,country,region,city,added,expires ,submitted) VALUES (?,?,?,?,?,?,?,?,?,?)");$result->execute($sitename,$siteurl,$category,$ description,$country,$region,$city,$added,$expires,$submitted); print $dbh->errstr(),"\n" unless ($result);$dbh->disconnect();
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 the right syntax to use near database(sitename,siteurl,category,description,country,region, at /home/gl/httpd/index.pl line 403., referer: http://gl.example.com/
I ran your code and it worked fine on my system.
What version of MySQL are you running? I have 3.23.43.
Here is the script I wrote: ( I created a new table called 'test' in the 'test' db )
------
#!/usr/bin/perl -w
use DBI;
$sitename = 'mysite';
$siteurl = 'myurl';
$category = 'foo';
$description = 'here is a description';
$country = 'usa';
$region = '1'; $city = 'ny';
$added = 'now';
$expires = 'never';
$submitted = 'today';
my $dbh = DBI->connect("DBI:mysql:test","root","");
my $result = $dbh->prepare("INSERT INTO test(sitename,siteurl,category,description,country,region,city,added,expires,submitted) VALUES (?,?,?,?,?,?,?,?,?,?)");
$result->execute($sitename,$siteurl,$category,$description,$country,$region,$city,$added,$expires,$submitted);
print $dbh->errstr(),"\n" unless ($result); $dbh->disconnect();
-------
This mail doesn't seem like it will help you. However, all I did was fix the line wraps in your code.
Thanatos
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]