CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
sql fetch data

 



webhay
Novice

Jun 13, 2001, 12:57 PM

Post #1 of 2 (779 views)
sql fetch data Can't Post

i designe database with mysql and i using this command to fetch data

$SQL = "select id,username,password from access where username='$username'";
&Do_SQL;

put where this comman store tha data .
and i want to make a loop to display all data

thanks



Cure
User

Jun 15, 2001, 8:29 PM

Post #2 of 2 (771 views)
Re: sql fetch data [In reply to] Can't Post

use DBI;

my $DSN = "DBI:mysql:db";
my $user = "you";
my $pw = "secret";


$dbh = DBI->connect($DSN,$user,$pw) or die "Cannot connect: $DBI::errstr\n";

my $query = " select id,username,password from access where username = ? ";

my $sth = $dbh->prepare($query) or die $DBI::errstr;
$sth->execute($username) or die $DBI::errstr;

while ( my($id,$username,$password) = $sth->fetchrow_array())
{
print " $id $username $password ";
}


Cure


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives