I am finally getting around to trying to learn how to work with classes. I have designed a class that, among other things, does a query. I have defined the following vars in my class:
var $table_name;
var $user_field;
I set the above vars in another php script like so:
$checkuser = &New ConnectTable; //create object $checkuser of class ConnectTable
$checkuser->table_name = "table_Users";
$checkuser->user_field = $forumname;
Now, my class works fine if I hard-code the query string like so:
$query = "SELECT * FROM table_Users WHERE ".U_Username." LIKE 'Fred'";
but if I try to use the vars using the $this-> constructor, I get an error: "Warning: Supplied argument is not a valid MySQL result resource "
I've tried every combo of quotes, single quotes, etc. and can't seem to get the syntax right.
For example:
$query = "SELECT * FROM ".$this->table_name." WHERE ".U_Username." LIKE ".$this->user_field."";
So my question is, if I want to use $this->table_name and $this->user_field in this query, what syntax do I use?
Thanks,
Basil