Inserting into a database using DBI

#!/usr/bin/perl
use DBI;
use strict;
my $username = "dbuser";
my $password = "dbpassword";
my $dsn = "dbi:mysql:goo:192.168.1.10";
my $dbh = DBI->connect($dsn,$username,$password)
or die <div><a href="http://viagraonline-rxcanada.com/">buy viagra online</a> . <a href="http://pharmacyrx-canadaonline.com/">canadian pharmacy</a> . <a href="http://levitrageneric-onlinecanada.com/">http://levitrageneric-onlinecanada.com/</a> . <a href="http://cialiscanada-onlinerx.com/">do i need a prescription for cialis</a> . <a href="http://levitrageneric-onlinecanada.com/">price comparison levitra</a> . <a href="http://pharmacyrx-canadaonline.com/">canadian pharmacy</a> . <a href="http://viagraincanada-onlinerx.com/">viagra generic</a></div>  "Cannot connect to database: $DBI::errstr";
my $sth = $dbh-&gt;prepare("INSERT INTO urls VALUES
('','http://www.w3mentor.com/','tutorials',unix_timestamp(),'query words')");
$sth-&gt;execute() or die "Cannot execute sth: $DBI::errstr";
$dbh-&gt;disconnect();

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.