hi,
I have date in this format
December 2 2009
December 2 2009
December 2 2009
and i want to insert it in my table in mysql .I m inserting this with the help of perl
means i m doing my program in perl .ook at my program
#!/usr/bin/perl
use Mysql;
use DBI;
my $dataSourceName = "DBI:mysql:database=redbytes_TestDrupal;host=localhost";
@file = "submission.csv";
my($date , $name ,$emailid , $phone ,$country ,@value , @raw_data);
# MYSQL CONFIG VARIABLES
$host = "localhost";
$database = "redbytes_TestDrupal";
$tablename = "submissionfiledata";
$user = "redbytes";
$pw = "N1nja2007";
# PERL MYSQL CONNECT()
$con = DBI->install_driver('mysql');
$con = $con->connect($dataSourceName, $user,$pw);
foreach my $filename(@file)
{
open(DAT,$filename)||die("Could not open file!");
@raw_data = <DAT>;
close(DAT);
print $filename(@raw_data);
foreach my $line(@raw_data)
{
chomp($line);
@value = split(',',$line);
$date = @value[0];
$name = @value[2];
$emailid = @value[3];
$phone = @value[5];
$country =@value[6];
#print($date);
if(!$con)
{
die('Could not connect: ' . mysql_error());
}
else
{
my $sql = "INSERT INTO submissionfiledata "."(date,Name,FromEmailid,PhoneNumber,CountryName) "."VALUES " ."('$date','$name','$emailid','$phone','$country')";
$query = $con->prepare($sql);
$query->execute();
if(! $query )
{
die('Could not enter data: ' . mysql_error());
}
}
}
}
print( "Entered data successfully\n");
when i run this then it inserting date 0000-00-00
but i want here date ...........
Plz help me