Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 17th, 2005, 09:40 AM
D. Alvarado
Guest
 
Posts: n/a
Default Trouble accessing class member variable

Hello, I am running PHP 4. I have this simple class,

class CTable {
var $m_name;
var $m_primary_key_col_name;
}

then I have a function that takes, as argument, an instance of this
class

function bar($p_table) {
$table_name = $p_table->m_name;

but I get this parse error

Parse error: parse error, unexpected T_VARIABLE in
/usr/local/apache/htdocs/dev/util_fns.php on line 35

I know this is some simple syntax thing. What am I doing wrong?

Thanks, - Dave
  #2  
Old July 17th, 2005, 09:40 AM
Michael Fesser
Guest
 
Posts: n/a
Default Re: Trouble accessing class member variable

.oO(D. Alvarado)
[color=blue]
>Hello, I am running PHP 4. I have this simple class,
>[...]
>
>but I get this parse error
>
>Parse error: parse error, unexpected T_VARIABLE in
>/usr/local/apache/htdocs/dev/util_fns.php on line 35[/color]

What is on line 35? Please post that line _and_ the lines before, if
possible all lines from the start. In many cases the cause for a parse
error is not found in the line where the interpreter recognizes it and
complains about it, but somewhere before.

Micha
  #3  
Old July 17th, 2005, 09:41 AM
Ron
Guest
 
Posts: n/a
Default Re: Trouble accessing class member variable

"D. Alvarado" <laredotornado@gmail.com> wrote in message
news:ec027e73.0409190700.4abc6006@posting.google.c om...[color=blue]
> Hello, I am running PHP 4. I have this simple class,
>
> class CTable {
> var $m_name;
> var $m_primary_key_col_name;
> }
>
> then I have a function that takes, as argument, an instance of this
> class
>
> function bar($p_table) {
> $table_name = $p_table->m_name;
>
> but I get this parse error
>
> Parse error: parse error, unexpected T_VARIABLE in
> /usr/local/apache/htdocs/dev/util_fns.php on line 35
>
> I know this is some simple syntax thing. What am I doing wrong?
>
> Thanks, - Dave[/color]

Dave,

First the dumb question,

you have actually instantiated the class before passing it to the function ?

$fred = new CTable();
.. . . . .
bar($fred);


Second , what is in line 34 of /usr/local/apache/htdocs/dev/util_fns.php ?
missing semicolons in the row above can cause havoc.

HTH

Ron


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles