Re: DBI and mySQL problems

2003-09-10 Thread Thanatos
Thanatos wrote:

Gavin Laking wrote:

Hi,

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/
 

Hi Gavin,

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



Oh yeah, one more thing. Are you trying to use the table name 'table'? 
If yes, then that may be your problem. ( I tried to create a table named 
table, just to be sure, and MySQL complained at me ).

Thanatos

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: DBI and mySQL problems

2003-09-10 Thread Thanatos
Gavin Laking wrote:

Hi,

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/
 

Hi Gavin,

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]


Re: HOW DO I INSTALL DBI/DBD Modules on Solaris 8

2002-11-16 Thread Thanatos
Charles Idonije wrote:

I need help installing DBI & DBD Modules on a server running Solaris 8.There are multiple instances of perl installed on this server. The question is how do I install DBI and DBD to point to a particular instance of perl. For example /apps/bin/perl.

Thanks,

[EMAIL PROTECTED]

 

 



-
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site

Hi Charles,

Have you tried using CPAN? Go here for info: http://cpan.perl.org.

Here is the command to get CPAN running with the perl instance you 
desire. ( As root )

/apps/bin/perl -MCPAN -e shell

After you answer the questions ( if CPAN needs to be configured ) you 
can see the available DBI & DBD modules with

i /DBI/
i /DBD/

To install, ( for mysql anyways :) )

instal DBD::mysql

I have never done anything with Solaris .. I hope this helps you :).

Thanatos



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: question about importing data in MS Access

2002-10-23 Thread Thanatos
Analbers, Luc wrote:

Hi,
 
Can anyone help me?
This is what I try to make:
 
I do have a Microsoft Access file on the network.
I would like to give our employees the opportunity to fill in a HTML form
(to be created in Dreamweaver) and send (store) the data to the shared
networkdirectory.
Once this is done, the data should be automatically imported in the database
and after succesfull import the sent data must be deleted automatically.
 
So generally it is about sending data (via HTML) to an Access 97 database.
 
Anyone solved this problem before?
Who can help me? What do I need to solve this issue?
 
Kind regards,
 
Luc
 
 
 
Luc Analbers 
Applicatiebeheerder  Redactie
Wegener Huis-aan-huis Kranten BV
Houten 
*:  [EMAIL PROTECTED] 
 





Hello Luc,

There is a perl module called DBD::ODBC. I have never used it but I have 
been told that you can connect to an Access database and insert records. 
( I do this all day using DBD::mysql on a MySQL database ).

What you need to do is have your HTML submit to a perl script that 
connects to the Access database and inserts the data.

Hope that helps,
Thanatos

p.s. You can read about the DBD::ODBC module here:
http://search.cpan.org/author/JURL/DBD-ODBC-0.43/ODBC.pm

Hope that helps,
Thanatos


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Regular expression

2002-09-12 Thread Thanatos

Javeed SAR wrote:
> 
> I have a statement as follows;
> I need to split them into 3 parts;
> 
> * test_merge1  \\blrk35ed\views\test_merge1.vws
> 
> 
> LIke this:
> $var1 should have *
> $var2 should have test_merge1
> $var3 should have  \\blrk35ed\views\test_merge1.vws
> 
> 
> 
> TIA
> 
> Jav
> 
> 
> 

how about

$foo = '* test_merge1 \\blrk35ed\views\test_merge1.vws';
$foo =~ m/^(\*)\s+(\w+)\s+(\\.*)$/;

$1,$2,$3 are special variables. they equal whatever is matched between 
each set of () successivly.

$1 will be *
$2 will be test_merge1
$3 will be \blrk35ed\views\test_merge1.vws

Note, if you want $3 to have two \\ you will need to add one like this:

my $tmp = $3;
$tmp = "\\$tmp";

or just add another \ to your string .. \\\blrk35ed\views\test_merge1.vws

Hope that works for ya,
Thanatos

privided ofcourse that the spaces are actually spaces and not tabs .. if 
they are tabs, replace \s+ with \t+



Thanatos


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Problems with perl and cron jobs

2002-09-08 Thread Thanatos

David Gerler wrote:
>>David Gerler wrote:
>>
>>>Hi all,
>>> I have a script that runs an SQL query and sends an email
>>
>>using sendmail.
>>
>>>It works fine if called using a browser. The email is sent with
>>
>>the correct
>>
>>>content in the message.
>>> If I run it using cron, I get the message but the content
>>
>>is not sent.
>>
>>>Meaning the body of the message is empty. I also get an email
>>
>>from cron that
>>
>>>contains and error message:
>>>---
>>>DBD::mysql::db do failed: You have an error in your SQL syntax
>>
>>near '' at
>>
>>>line 1 at /home/ezbid/www/cgi-bin/ua/includes/close_item.pl line 248.
>>>--
>>>
>>> Can anybody give me some insight as to why I get an error when cron
>>>executes the script, but when I do it in a browser it works fine.
>>>
>>> Any help is appreciated.
>>>
>>>David Gerler
>>>Gerler Enterprises
>>>PO BOX 16357
>>>Chesapeake VA 23328
>>>http://www.GerlerEnterprises.com/
>>>
>>>Nationwide Dial-up from $12.45
>>>http://www.EasySitesForLess.com/
>>>
>>>
>>>
>>>
>>
>>I ( we ) would need to see the script(s) that cron is calling to help
>>out. However, I get that DBD error all the time :-) .. are you sure your
>>sql statement is correct?
>>
>>Thanatos
>>
> 
> The script runs when called from a browser so I was thinking that it had to
> do with the differences in how apache and cron worked or something like
> that, so I didn't include the code. I will include the code below:
> 
> This is the sql statement from line 248:
> $db->do("UPDATE Members SET won=won + 1 WHERE usernum=$biddernum");
> 
> This is the job I set in cronjobs:
> * * * * *   /home/ezbid/www/cgi-bin/ua/item.pl?item=958 > /dev/null
> 
> I'm new to SQL also, so could the spaces around the "+" be the problem?
> 
> Dave
> 
> 
> 

Thanks Dave,

 From the looks of the SQL statement, won is an integer and you want to 
add one to it. When I do that I get the current value of won from the db 
, assign the value to a variable ( like $won ) and then do a ("update 
Memebers SET won='" . ( $won + 1 ) . "' WHERE ..." ).

Also, is $biddernum defined and does it contain a value? Is it possible 
that it could contain special characters, like a ' or "? If so, the you 
can use $new_biddernum = $db->quote( $biddernum ) so that the special 
chars are taken care of for you.

For an explaination of $db->quote, do a man DBI and search for quote.

Does any of that help?
Thanatos



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Problems with perl and cron jobs

2002-09-08 Thread Thanatos

David Gerler wrote:
> Hi all,
>   I have a script that runs an SQL query and sends an email using sendmail.
> It works fine if called using a browser. The email is sent with the correct
> content in the message.
>   If I run it using cron, I get the message but the content is not sent.
> Meaning the body of the message is empty. I also get an email from cron that
> contains and error message:
> ---
> DBD::mysql::db do failed: You have an error in your SQL syntax near '' at
> line 1 at /home/ezbid/www/cgi-bin/ua/includes/close_item.pl line 248.
> --
> 
>   Can anybody give me some insight as to why I get an error when cron
> executes the script, but when I do it in a browser it works fine.
> 
>   Any help is appreciated.
> 
> David Gerler
> Gerler Enterprises
> PO BOX 16357
> Chesapeake VA 23328
> http://www.GerlerEnterprises.com/
> 
> Nationwide Dial-up from $12.45
> http://www.EasySitesForLess.com/
> 
> 
> 
> 

I ( we ) would need to see the script(s) that cron is calling to help 
out. However, I get that DBD error all the time :-) .. are you sure your 
sql statement is correct?

Thanatos



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]