#!/usr/bin/perl -w # commit.pl # CREATE table people ( # ID varchar(10) not null primary key, # NAME varchar(100) DEFAULT '', # EMAIL varchar(100) DEFAULT '', # STREET varchar(100) DEFAULT '', # CITY varchar(100) DEFAULT '', # STATE varchar(10) DEFAULT '', # ZIP varchar(20) DEFAULT '', # COUNTRY varchar(60) DEFAULT '', # ADD_DATE date # ); use strict; use CGI ':standard'; use DBI; my $name = param('name') || ''; my $id = param('id') || ''; my $email = param('email') || ''; my $city = param('city') || ''; my $state = param('state') || ''; my $zip = param('zip') || ''; my $street = param('street') || ''; my $country = param('country')|| ''; if ( param('go') eq 'Commit Changes' ) { print header; my $dbh = DBI->connect('DBI:mysql:3s','root','') || die $DBI::errs +tr; my $sth = $dbh->prepare( q{ UPDATE people SET NAME = ?, SET EMAIL = ?, SET STREET = ?, SET CITY = ?, SET STATE = ?, SET ZIP = ?, SET COUNTRY = ?, where ID = $id } ) || die $DBI::errstr; $sth->execute( $name , $email , $street , $city , $state , $zip , $cou +ntry ) || print $DBI::errstr ; $sth->finish(); $dbh->disconnect(); print "$name $id $email $city $state $zip $street $country" ; }
In reply to SQL UPDATE and DBI for MySQL by silent11
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |