in reply to DBI connection through CGI
$dbHandle = DBI->connect('DBI:mysql:mydb','ID','pw');
my $dbh = DBI->connect("DBI:mysql:database=dbname;host=host", "$id","$ +pw") || die "Can't connect: $DBI::errstr";
Warning: This code is untested but it should help you complete the project.#!/usr/bin/perl -wT use strict; use CGI qw( :standard ); use CGI::Carp qw( fatalsToBrowser ); use DBI; use DBD::mysql; #Store each field in a variable. my $name = param("name"); my $phone = etc.. my $age = etc.. my $sth; #Then insert each of them into a table: $sth = $dbh->prepare("INSERT INTO userdata VALUES (?,?,?)"); $sth->execute($name, $phone, $age); #Make sure you clean up when finished: $sth->finish(); $dbh->disconnect();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: DBI connection through CGI
by Phemur (Beadle) on May 20, 2002 at 21:30 UTC |