afidegnum
Posts: 16
|
Posted: 03/08/2008, 8:17 AM |
|
Hello good morning all,
I have written a code that will upload a csv file and parse the content to the database. as below:
after uploading the files, the contents are uploaded to the database all right.
according to the code, it suppose to give me a result of parsed row and the line parsed.
with this code: echo "<p> $num fields in line $row: <br /></p>\n";
but nothing happens. after uploading the file and submitting, the same page stands still. looking at me but the file contents upload to the database all right.
even the url give me an empty variable:.
http://localhost/responser/prospects_imp.php? there is suppose to be a variable appended to it.
I even put the variables on global but it was rather preaching in the desert. below is the event code.
I am confused. I need your assistance please.
========================pros_event.php====================================
<?php
//BindEvents Method @1-256065C0
function BindEvents()
{
global $importForm;
$importForm->FileUpload1->CCSEvents["AfterProcessFile"] = "importForm_FileUpload1_AfterProcessFile";
}
//End BindEvents Method
//importForm_FileUpload1_AfterProcessFile @3-BCC88CC8
function importForm_FileUpload1_AfterProcessFile(& $sender)
{
$importForm_FileUpload1_AfterProcessFile = true;
$Component = & $sender;
$Container = & CCGetParentContainer($sender);
global $importForm; //Compatibility
//End importForm_FileUpload1_AfterProcessFile
//Custom Code @9-2A29BDB7
// -------------------------
if(!strlen($Container->FileUpload1->GetValue()))
{
//$import->Errors->addError("No Upload File - Please try again ") ;
echo"File not uploaded";
} else {
$file = $Container->FileUpload1->FileFolder.$Container->FileUpload1->GetValue();
//$file = 'upload/' . $Container->FileUpload1->GetValue() ;
//{
//$import->Errors->addError("Error Processing File - Please try again ") ;
//echo"Error reading file";
//}
$db = new clsDBresponder();
$handle = fopen($file,"r");
$row = 1;
$handled = fopen("$handle", "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
global $num;
global $row;
echo "<p> $num fields in line $row: <br /></p>\n";
$row++;
$SQL = "INSERT INTO prospects (pros_fname,pros_lname,pros_email) values('$data[0]','$data[1]','$data[2]')";
$db->query($SQL);
$db->close();
}
fclose($handled);
}
// -------------------------
//End Custom Code
//Close importForm_FileUpload1_AfterProcessFile @3-6A65C376
return $importForm_FileUpload1_AfterProcessFile;
}
//End Close importForm_FileUpload1_AfterProcessFile
?>
============================================================
|
|
|
|
|
|
|
|