Problem calling function within a class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi

i am new to classes and i have a problem with a class i wrote

here is the class

-----------------------------------------------------------------------
class Company {
	
	
	var $Company_Name;
	var $Company_Referrer_Table;
	var $Company_Visitor_Table;
	var $Company_ID;
	var $Message;
	var $File;
	var $FileName;
	var $Record_Data;
	
	
	function CompanyInfo (){
		
		
		
		$SQL_Query = mysql_query("SELECT * FROM company_list WHERE
Company_ID = $this->Company_ID");
		$Record = mysql_fetch_array($SQL_Query);
		
		$this->Company_ID = $Record['Company_ID'];
		$this->Company_Name = $Record['Company_Name'];		
		$this->Company_Referrer_Table = $Record['Company_Referrer_Table'];
		$this->Company_Visitor_Table = $Record['Company_Visitor_Table'];
		
		return $this->Company_Referrer_Table;
		return $this->Company_Visitor_Table;
		
	}		
	
	
	function GenerateUniqueID(){
		
		return md5(uniqid(mt_rand(),TRUE));
		
	}
	
	
	function UploadFile($File) {
		
		$this->File = $File;
		$dst_file_name = $this->GenerateUniqueID();
		$arr = split("\.",$this->File['name']);
		$this->File['name'] = $dst_file_name;
		$this->File['name'] .= ".".$arr[count($arr)-1];
		$dest_dir = 'temp';
		$dest = $dest_dir . '/' .$this->File['name'];
		$r = move_uploaded_file($this->File['tmp_name'], $dest);
		$this->FileName = $this->File['name'];
		chmod("temp/".$this->FileName, 777);
		
		
	}
	
	function TakeData($File, $Company_ID, $Destination) {
		
		$this->Company_ID = $Company_ID;
		
		$this->CompanyInfo();
		

		
		if ($Destination == "Referrer"){
			
			$SQL_Query = "INSERT INTO $this->Company_Referrer_Table ( Record_ID
, Record_Data ) VALUES ( '', '$this->Record_Data')";
			
		}elseif ($Destination == "Visitor"){
			
			$SQL_Query = "INSERT INTO $this->Company_Visitor_Table ( Record_ID
, Record_Data ) VALUES ( '', '$this->Record_Data')";
			
		}
		
		$this->UploadFile($File);
		
		$fh = fopen("temp/".$this->FileName, "r");
		while (! feof($fh)) : $this->Record_Data = fgets($fh, 4096);
		mysql_query($SQL_Query)or die("Error In Importing Records To The Database");
		endwhile;
		fclose($fh);
		
		$this->Message = "Date Imported Successfully";
		return $this->Message; 
		
	}
	
	
	
}

-------------------------------------------------------------------------------

the problem occurs when i call the function TakeDate 

i use this code to call it 

$Company = new Company();
$File =& $HTTP_POST_FILES['FileToUpload'];
$Company->TakeData($File, $Company_ID, $Destination);
$Message = $Company->Message;

the error i get is "Error In Importing Records To The Database" which
i defined as the error of mysql in the function.

i checked everything and found that the problem happens because i
can't retireve the values of
$this->Company_Referrer_Table and $this->Company_Visitor_Table by
calling the function CompanyInfo
from the function TakeData



can anyone advise me with the right way to call the CompanyInfo
function from the TakeData and get the values correctly?




-- 
Ahmed Abdel-Aliem
Web Developer
www.ApexScript.com
0101108551
registered Linux user number 382789

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux