PDA

View Full Version : How to Connect to MYSQL?


MRPerl
11-27-2003, 01:08 AM
Hello,
I can't find any tutorials on how to connect to a MYSQL Database. Any help would be appreciated.
Thank you

gish
11-27-2003, 07:51 PM
This will connent to the db.


use DBI;
use DBD::mysql;
$dsn = "DBI:mysql:database=your_database_name";
$user = "username";
$pass = "password";

#connect
$_[0] = DBI->connect($dsn,$user,$pass) || die "couldn't connect! $DBI::errstr

#disconnect
$_[0]->disconnect;

imported_scavok
03-26-2004, 10:48 AM
any chance of an example of how to create a table/variable/value?

I'm decent with perl but never used it with MYSQL before but would like to learn!

thanks!