View Single Post
Old 06-12-2010, 11:09 PM   #1 (permalink)
pipesportugal
The Contributor
 
pipesportugal's Avatar
 
Join Date: May 2008
Location: Oporto-Portugal
Posts: 32
Thanks: 11
pipesportugal is on a distinguished road
Default retreiving information from the class

PHP Code:
// class name is record
// number of records is 1.
// vector_fields is an array with the fieldnames in the table 
// The field names are like: code_customer, name_customer, and so on.

//*************************************
while ($row2 mysql_fetch_array($this->result_sql)) {
  for(
$j0$j<count($this->vector_fields); $j++) {
     
$firstpartstring $this->vector_fields[$j];
     
$stringfieldname 'scr_'.$firstpartstring;
     
$this->$stringfieldname $row2['$firstpartstring'];
  } 
// END of for
// END of while

//*************************************
// From the main program I want to retrieve the name of the customer with:
//  $customer = new record();
//  $customer_invoice = $customer->scr_name_customer; 
I am geting the following error:
Catchable fatal error: Object of class registo could not be converted to string in /home/vnhdpwxq/public_html/classes/classe_ler_registos.php on line 68

I believe it is because of the sentence:

PHP Code:
$this->$stringfieldname 
The program is not expecting the "$" on the stringfieldname variable.
What I really need is to make a $this->scr_name_customer.

Can someone help me overpass this problem?

I have completely run out of ideas.

Thanks in advance,
PP

Last edited by pipesportugal : 06-12-2010 at 11:21 PM. Reason: mistake
pipesportugal is offline  
Reply With Quote