this one really works, thank you so much to all who responded...
At 11:49 PM 2/4/01 -0700, Colin Faber wrote:
>[EMAIL PROTECTED] wrote:
>>hi list,
>>
>>im trying to write a perl srcipt that will connect to a mysql database
>>server, do some queries and print the output on the screen (or maybe append
>>the output to a file), that would look something like this.
>>
>>+------+-------+----------+-------------+
>>| tnum | user | cust | area |
>>+------+-------+----------+-------------+
>>| 22 | nivra | testing | isdn |
>>| 23 | nivra | testing1 | ddu |
>>| 24 | nivra | testing1 | ddu |
>>+------+-------+----------+-------------+
>>
>>below is my perl script.
>>
>>#!/usr/bin/perl
>>
>>use DBI;
>>
>>$dbname= "dbname";
>>$dbuser = "dbuser";
>>$dbpass = "dbpass";
>>$dbhost = "localhost";
>>$dbport = "3306";
>>$dsn = "DBI:mysql:database=$dbname;host=$dbhost;port=$dbport";
>>
>>$condition = " where date >= '2001/01/27' and petsa <= '2001/01/31' and
>>user = 'user'";
>>
>> # Connect to the database
>> $dbh = DBI->connect($dsn, $dbuser, $dbpass);
>>
>> # if needed and execute the SELECT
>> $sth = $dbh->prepare("SELECT tnum, user, type, area, stat FROM
>> tickets$where ") || die $dbh->errstr;
>> $sth->execute;
> while(my $ref = $sth->fetchrow_hashref()){
> print
> "$ref->{tnum}|$ref->{user}|$ref->{type}|$ref->{area}|$ref->{stat}\n";
> }
> # or something along those lines
>># clean up & disconnect from the DB
>> $sth->finish;
>> $dbh->disconnect;
>>
>>but it doesn't give me any output at all. i'd like to know if there is any
>>special parameter to use with sth->execute to do this. did i miss anything
>>here?
>>
>>thanks for your time.
>>
>>---------------------------------------------------------------------
>>Before posting, please check:
>> <http://www.mysql.com/manual.php>http://www.mysql.com/manual.php
>> (the manual)
>> <http://lists.mysql.com/>http://lists.mysql.com/ (the list
>> archive)
>>
>>To request this thread, e-mail <[EMAIL PROTECTED]>
>>To unsubscribe, e-mail <[EMAIL PROTECTED]>
>>Trouble unsubscribing? Try:
>><http://lists.mysql.com/php/unsubscribe.php>http://lists.mysql.com/php/unsubscribe.php