![]() |
$this Out of Context
Having a wierd problem with a class i'm trying to write
[PHP] public static function getID($username) { $username = $this->db->escape($username);//this line erros $sql = "SELECT u_id FROM ".$this->settings['users_table']."WHERE " .$this->settings['username_col']."='".$username."'"; $res = $this->db->query($sql); $res = $this->db->fetchArray($res); $id = $res['u_id']; return $id; } [/PHP] The error message "Using $this when not in object context". Not really sure what I'm doing wrong, and I used the same line in other lines and it does not error. Thanks |
[PHP] $sql = "SELECT u_id FROM ".$this->settings['users_table']."WHERE ";[/PHP]
shouldnt that code be like that. |
I don't think so, as he is connecting it to the string below that line with the "." operator.
|
The onlt thing that is wrong with that line is there needs to be a space between the " and the W in where.
The problem was because the method is static it has no instance, I wasn't aware things worked like that mabey it is a wrinkle in PHP's OOP model. |
Static methods don't have instances; that's why they're made static - share and share alike.
|
| All times are GMT -5. The time now is 4:35 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC