CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Error Opening File using $Containers

Print topic Send  topic

Author Message
afidegnum

Posts: 16
Posted: 03/04/2008, 9:52 AM

Hello, good morning,

I am writing an event code to open and read a csv file. Before Process: and I god the following error

Catchable fatal error: Object of class clsFileUpload could not be converted to string in C:\wamp\www\responser\prospects_imp_events.php on line 27


this is the following code:

it is a file upload file component,


=============================================================

<?php
//BindEvents Method @1-113D0652
function BindEvents()
{
global $importForm;
$importForm->FileUpload1->CCSEvents["BeforeProcessFile"] = "importForm_FileUpload1_BeforeProcessFile";
}
//End BindEvents Method

//importForm_FileUpload1_BeforeProcessFile @3-DBCE0183
function importForm_FileUpload1_BeforeProcessFile(& $sender)
{
$importForm_FileUpload1_BeforeProcessFile = true;
$Component = & $sender;
$Container = & CCGetParentContainer($sender);
global $importForm; //Compatibility
//End importForm_FileUpload1_BeforeProcessFile

//Custom Code @9-2A29BDB7

if(!strlen($Container->FileUpload1->GetValue()))
{

$import->Errors->addError("No Upload File - Please try again ") ;

} else {
$file = "$Container->FileUpload1->TemporaryFolder.$Container->FileUpload1->GetValue()";

{

$import->Errors->addError("Error Processing File - Please try again ") ;

}
$db = new clsDBConnection1();

$handle = fopen($file,"r");

$row = 1;
$handled = fopen("$handle", "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
echo "<p> $num fields in line $row: <br /></p>\n";
$row++;
for ($c=0; $c < $num; $c++) {
echo $data[$c] . "<br />\n";
$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_BeforeProcessFile @3-F4C24C40
return $importForm_FileUpload1_BeforeProcessFile;
}
//End Close importForm_FileUpload1_BeforeProcessFile


?>
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.