Need a little help here. My code not working
Below is my code and I do not know what is wrong with it ... It did not show any error and all 'echo' no result at all. Any help I get will be very much appreciated.
PHP Code:
<?php
require_once 'Excel/reader.php' ;
$data = new Spreadsheet_Excel_Reader ();
$data -> setOutputEncoding ( 'CP1251' );
$data -> read ( 'sample.xls' );
$conn = mysql_connect ( "localhost" , "root" , "" );
$link = mysql_select_db ( "asiaone" , $conn );
for ( $x = 9 ; $x <= count ( $data -> sheets [ 0 ][ "cells" ]); $x ++) {
$sn = $data -> sheets [ 0 ][ "cells" ][ $x ][ 1 ];
echo $sn ;
$invoiceno = $data -> sheets [ 0 ][ "cells" ][ $x ][ 2 ];
//echo $invoiceno."</br>";
$invoicedate = $data -> sheets [ 0 ][ "cells" ][ $x ][ 3 ];
//echo $invoicedate."</br>";
$customername = $data -> sheets [ 0 ][ "cells" ][ $x ][ 4 ];
//echo $customername."</br>";
$code = $data -> sheets [ 0 ][ "cells" ][ $x ][ 5 ];
//echo $code."</br>";
$suminsured = $data -> sheets [ 0 ][ "cells" ][ $x ][ 6 ];
//echo $suminsured."</br>";
$code2 = $data -> sheets [ 0 ][ "cells" ][ $x ][ 7 ];
//echo $code2."</br>";
$premiumbeforegst = $data -> sheets [ 0 ][ "cells" ][ $x ][ 8 ];
//echo $premiumbeforegst."</br>";
$gst = $data -> sheets [ 0 ][ "cells" ][ $x ][ 9 ];
//echo $gst."</br>";
$premiumaftergst = $data -> sheets [ 0 ][ "cells" ][ $x ][ 10 ];
//echo $premiumaftergst."</br>";
$commissionpercent = $data -> sheets [ 0 ][ "cells" ][ $x ][ 11 ];
//echo $commissionpercent."</br>";
$commissionamount = $data -> sheets [ 0 ][ "cells" ][ $x ][ 12 ];
//echo $commissionamount."</br>";
$payableto = $data -> sheets [ 0 ][ "cells" ][ $x ][ 13 ];
//echo $payableto."</br>";
$commissionamount2 = $data -> sheets [ 0 ][ "cells" ][ $x ][ 14 ];
//echo $commissionamount2."</br>";
$insuredname = $data -> sheets [ 0 ][ "cells" ][ $x ][ 15 ];
//echo $insuredname."</br>";
$policyno = $data -> sheets [ 0 ][ "cells" ][ $x ][ 16 ];
//echo $policyno."</br>";
$typeofpolicy = $data -> sheets [ 0 ][ "cells" ][ $x ][ 17 ];
//echo $typeofpolicy."</br>";
$periodofcover = $data -> sheets [ 0 ][ "cells" ][ $x ][ 18 ];
//echo $periodofcover."</br>";
$voucherno = $data -> sheets [ 0 ][ "cells" ][ $x ][ 19 ];
//echo $voucherno."</br>";
$customerpaymentdate = $data -> sheets [ 0 ][ "cells" ][ $x ][ 20 ];
//echo $customerpaymentdate."</br>";
$sql = "INSERT INTO test_import_excel (S/N, InvoiceNo, InvoiceDate, CustomerName, Code, SumInsured, Code2, PremiumBeforeGST, GST, PremiumAfterGST, CommissionPercent,CommissionAmount, PayableTo, CommissionAmount2, InsuredName, PolicyNo, TypeOfPolicy, PeriodOfCover, VoucherNo, CustomerPaymentDate) VALUES (' $sn ', ' $invoiceno ', ' $invoicedate ', ' $customername ', ' $code ', ' $suminsured ', ' $code2 ', ' $premiumbeforegst ', ' $gst ', ' $premiumaftergst ', ' $commissionpercent ', ' $commissionamount ', ' $payableto ', ' $commissionamount2 ', ' $insuredname ', ' $policyno ', ' $typeofpolicy ', ' $periodofcover ', ' $voucherno ', ' $customerpaymentdate ');" ;
//echo $sql."\n";
//mysql_query($sql);
}
?>
Try adding this to the very beginning of your code:
PHP Code:
<?php
ini_set ( 'display_errors' , true ); // set to false in production version
error_reporting ( E_ALL );
// rest of code...
?>
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in
Nation
eBookworm.us
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks