Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mysql with perl

Status
Not open for further replies.

teao

Technical User
Jul 14, 2003
3
PH
simple sample program using perl in database(mysql).
 
Hi,

use DBI;
$dbh=DBI->connect("dbi:mysql:database=test","user","password");
$dbh->do("INSERT INTO sometable(column) VALUES(value)");
$sth=$dbh->prepare("SELECT * FROM test");
$sth->execute();
while($sth->fetchrow_array())
{
print $_;
}
$sth->finish()
$dbh->disconnect();

Also you may read the DBI manual with "perldoc DBI".

Hope that helps

--
Smash your head on keyboard to continue...
 
correction:

not:
$sth=$dbh->prepare("SELECT * FROM test");

but:
$sth=$dbh->prepare("SELECT something FROM test");

because thats easier for the "print $_;" below.

Greetings

--
Smash your head on keyboard to continue...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top