Forum Moderators: coopster
Any insight into this irregularity would be much appreciated :-)
function _db_connect() {
$this->link_id=@mysql_connect($this->host, $this->user,
$this->pass) or die("Could not connect to database");
if(!$this->link_id) {
return FALSE;
}
$db=@mysql_select_db($this->db) or die ("can't select db");
return TRUE;
}
and here is the function it fails in....
function change_password($email, $new_password) {
$new_password=md5($new_password); // encryption
$qry="UPDATE $this->table SET pass = '$new_password' ";
$qry.="WHERE email = '$email'";
if(!$this->_db_connect()) {
return FALSE;
}
if(!($result=mysql_query($qry, $this->link_id))) {
return FALSE;
} else {
if(mysql_affected_rows()==0) {
return FALSE;
} else {
$this->set_pass($new_password);
}
}
return TRUE;
}
Now to the program....
$this->table is not set.
Is this inside a class? You may want to include the whole class. Looks like I am missing code here.
I've kinda worked out whats causing it but not why....
It seems that passing the object in a session and trying to use the db methods on a page other than the one the object was instantiated on messes it up.
God knows why....
But just starting a new instance of the object and making calls to the db methods with that object works fine.
There is no reason I can see that would make it 'deny access' like this but a solution has been reached anyway :-)
Cheers
Nick
as for the _underlines. Not so, in classes it is a way of seperating private from public methods and other than being a tidy convention has no effect on the code.
as for $this->table not being set: firstly the problem does not occur here. it is 'Access denied' by mysql when the program attempts to conect, not query.
It is indeed in a class and naturally the whole class is included. (otherwise how would I access these methods?)
Anyway, hope my last post makes sense :-)
Cheers
Nick