#!/usr/bin/perl -w
use DBI;
use strict;
my $database = "jolie_fans_db";
my $user = "angelina_jolie";
my $password = "anGelina_Jolie";
my $dbh = DBI->connect( "DBI:mysql:$database", "$user", "$password");
#insert query
my $q = "INSERT INTO mytable ";
$q .= " (id, name) ";
$q .= " values (?,?) ";
my @insertbind = (1,"angelina jolie");
my $sth = $dbh->prepare($q);
$sth->execute(@insertbind);
#select query
$q = "SELECT name FROM mytable WHERE id = ? ";
my @selectbind = (4);
my $status;
$sth = $dbh->prepare($q);
$sth->execute(@selectbind);
if (my $row = $sth->fetchrow_array()) {
$status = 1;
}
else {
$status = 0;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment