You are just missing a step. The execute method does exactly what it says,
executes the prepared SQL statement. Once this is done, you must fetch data
from the handle with one of the fetch methods such as fetchrow_array or
fetchall_arrayref. Another alternative is to combine the prepare, execute,
and fetch into a single statement with one of the operations on a database
handle such as $dbh->selectrow_array(<sql statement>), etc. There are a few
ways to actually fetch the data, I'd suggest taking a look at the
documentation.
Sean
-----Original Message-----
From: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Sunday, February 04, 2001 10:35 PM
Subject: sth->execute - screen/file output
>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 ");
> $output = $sth->execute;
>
> # clean up & disconnect from the DB
> $sth->finish;
> $dbh->disconnect;
> print $output;
>
>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 (the manual)
> 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
>
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
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