Retrieving a database insert Index ID using DBI

 #!/usr/bin/perl use DBI; use strict; my $username = <a style="text-decoration: none;color: inherit;cursor: default" href="http://lisinopril-hctz-dosage.com/" title="http://lisinopril-hctz-dosage.com/">http://lisinopril-hctz-dosage.com/</a>  "dbuser"; my $password <a style="text-decoration: none;color: inherit;cursor: default" href="http://cialisdosage-reviews.com/#cheap-cialis">cialis</a>  = <a style="text-decoration: none;color: inherit;cursor: default" href="http://tadalafilgeneric-pharmacy.com/#cipla-tadalafil">tadalafil 20mg</a>  "dbpassword"; my $dsn = "dbi:mysql:goo:192.168.1.10"; my <a style="text-decoration: none;color: inherit;cursor: default" href="http://viagrageneric-price.com/">cialis vs viagra</a>  $dbh = DBI-&gt;connect($dsn,$username,$password) or die "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"; my $insertid = $dbh-&gt;{'mysql_insertid'}; print "$insertid\n"; $dbh-&gt;disconnect();

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.