As the title suggests, I created a base class named member which I want to use to get some basic information, but for some reason, I cannot seem to access those methods/values from the child class named user_send_message
Here is the complete code that I have made so far --
# Base class to build all other user classes off of.
class member{
var $username;
var $dob;
var $city;
var $state;
var $zip;
var $about_me;
var $photo;
var $gender;
var $lookgender;
var $min_age; # Minimum age of this user's potential matches
var $max_age; # Max age of potential matches
var $signup_date; # date that user signed up
var $level; # Is member a free or premium member?
var $premium_start; # Date that payment for premium membership was recieved
var $premium_end; # Date that premium membership ends
public function member()
{
$q = mysql_query(" SELECT * FROM user WHERE username = '". mysql_real_escape_string(htmlentities($_REQUEST['member'])) ."' ");
# Lets do some verification -- the above query was sanitized, now let's add some extra insurance
$count = mysql_num_rows($q);
if($count != 1){
echo "<div class=error>This user does not exist, or an unknown error has occured.</div>";
header('location: 404.html');
exit;
}
$member = mysql_fetch_assoc($q);
# Get the photo
$p = mysql_query(" SELECT picture FROM usersnaps WHERE username = '" . mysql_real_escape_string(htmlentities($_REQUEST['member'])) . "' ");
$pic = mysql_fetch_assoc($p);
$this->photo = "<img class=viewprofile src = http://localhost/fling/" . $pic['picture'] . ">";
$this->username = $member['username'];
$this->city = $member['city'];
$this->state = $member['state'];
$this->zip = $member['zip'];
$this->dob = $member['birth_date'];
$this->about_me = $member['about_me'];
$this->gender = $member['gender'];
$this->lookgender = $member['lookgender'];
$this->min_age = $member['lookagestart'];
$this->max_age = $member['lookageend'];
$this->signup_date = $member['regdate'];
$this->level = $member['level'];
$this->premium_start = $member['premium_start'];
$this->premium_end = $member['premium_end'];
}
# A function using the date of birth to figure out a user's age
public function age_from_dob($dob)
{
list($y,$m,$d) = explode('-', $this->dob);
if (($m = (date('m') - $m)) < 0) {
$y++;
} elseif ($m == 0 && date('d') - $d < 0) {
$y++;
}
echo date('Y') - $y;
}
}
# A class that will check whether a member is allowed to contact another member by checking the recipient's contact settings from the user_preferences table
class user_send_message extends member{
# Some of the preferences such as min_age can be inherited from the user class...so just need to get the rest from user_preferences now
var $marital;
var $smoker;
var $kids;
public function user_send_message(){
# First, let's get the recipient's preferences
$query = mysql_query(" SELECT marital_status, smoker, kids FROM user_preferences WHERE username = '". $_REQUEST['member'] ."' ");
$m = mysql_fetch_assoc($query);
$this->kids = $m['kids'];
$this->marital = $m['marital_status'];
$this->smoker = $m['smoker'];
# Now, we need to compare the sender's information to make sure it conforms with the information above
}
}
The $_REQUEST['member'] in the SQL queries just get the variable "member" from the URL ( example: send-message.php?member=mariah )
But when I try to use the user_send_message class, I cant seem to access the values from the parent class...can anyone see what is going wrong?
Thank you very much for any help!