ALL:
I recently purchased a new server. I tried this snippet of code on it and everything worked well - but the execution failed
Can anyone help please.
use warnings;
use strict;
use CGI qw(:standard);
use DBI;
#---------------------------------------------------------
sub Connect;
sub Insert;
sub Validate;
sub PostOnFly;
#---------------------------------------------------------
print header();
print start_html(title => "Bizz5" );
my( $val,%vals,$dbc );
$val = new CGI;
%vals = $val->Vars;
Validate();
$dbc = Connect("bizz","maha");
Insert($dbc);
$dbc->disconnect();
print end_html();
#---------------------------------------------------------
sub Connect
{
my($user,$pass) = @_;
my($dbc);
$dbc = DBI->connect("DBI:mysql:host=localhost;database=bizzhel_bizzhelper",$user,$pass,{PrintError=>0,RaiseError=>1} );
return $dbc;
}
#---------------------------------------------------------
sub Validate
{
foreach my $k( %vals )
{
if($vals{$k} eq "" )
{
if( $k eq "name" || $k eq "company" || $k eq "phone" || $k
eq " email" || $k eq "where" || $k eq "comments" ) {
print "<html><head>\n";
print "<script Language=\"JavaScript\">\n";
print " alert(\"All required fileds must be filled out\");\n";
print "history.back()\;";
print "</script></head></html>\n"; exit;
}
}
$vals{$k} =~ s/^\s+//;
$vals{$k} =~ s/\s+$//;
}
}
#---------------------------------------------------------
sub Insert
{
my($dbc) = @_;
my( $dbs,$count,$datetime,$pass,$user,$count,$number );
$dbs = $dbc->prepare("INSERT INTO franchise( name,company,email,phone,where,comments,password,username,datetime) VALUES(?,?,?,?,?,?,?,?,?)");
$datetime = localtime;
$count = 0;
$pass = "pass";
$user ="user";
srand(time|$$);
$number = int(rand(1000)) + 1;
$pass .= $number;
$number = int(rand(1000)) + 1;
$user .= $number;
THE CODE FAILS HERE.
-----------------------------
$count = $dbs->execute($vals{name},$vals{company},$vals{email},$vals{phone},$vals{where},$vals{comments},$pass,$user,$datetime);
if( $count != 0 )
{
&PostOnFly();
}
$dbs->finish();
}
#---------------------------------------------------------
sub PostOnFly
{
not done yet
}
I recently purchased a new server. I tried this snippet of code on it and everything worked well - but the execution failed
Can anyone help please.
Code:
#!/usr/bin/perl use warnings;
use strict;
use CGI qw(:standard);
use DBI;
#---------------------------------------------------------
sub Connect;
sub Insert;
sub Validate;
sub PostOnFly;
#---------------------------------------------------------
print header();
print start_html(title => "Bizz5" );
my( $val,%vals,$dbc );
$val = new CGI;
%vals = $val->Vars;
Validate();
$dbc = Connect("bizz","maha");
Insert($dbc);
$dbc->disconnect();
print end_html();
#---------------------------------------------------------
sub Connect
{
my($user,$pass) = @_;
my($dbc);
$dbc = DBI->connect("DBI:mysql:host=localhost;database=bizzhel_bizzhelper",$user,$pass,{PrintError=>0,RaiseError=>1} );
return $dbc;
}
#---------------------------------------------------------
sub Validate
{
foreach my $k( %vals )
{
if($vals{$k} eq "" )
{
if( $k eq "name" || $k eq "company" || $k eq "phone" || $k
eq " email" || $k eq "where" || $k eq "comments" ) {
print "<html><head>\n";
print "<script Language=\"JavaScript\">\n";
print " alert(\"All required fileds must be filled out\");\n";
print "history.back()\;";
print "</script></head></html>\n"; exit;
}
}
$vals{$k} =~ s/^\s+//;
$vals{$k} =~ s/\s+$//;
}
}
#---------------------------------------------------------
sub Insert
{
my($dbc) = @_;
my( $dbs,$count,$datetime,$pass,$user,$count,$number );
$dbs = $dbc->prepare("INSERT INTO franchise( name,company,email,phone,where,comments,password,username,datetime) VALUES(?,?,?,?,?,?,?,?,?)");
$datetime = localtime;
$count = 0;
$pass = "pass";
$user ="user";
srand(time|$$);
$number = int(rand(1000)) + 1;
$pass .= $number;
$number = int(rand(1000)) + 1;
$user .= $number;
THE CODE FAILS HERE.
-----------------------------
$count = $dbs->execute($vals{name},$vals{company},$vals{email},$vals{phone},$vals{where},$vals{comments},$pass,$user,$datetime);
if( $count != 0 )
{
&PostOnFly();
}
$dbs->finish();
}
#---------------------------------------------------------
sub PostOnFly
{
not done yet
}