I'm trying to insert data into the database
I get it from a form, send it via POST and pass the values from POST to class variables. Then i use this to create the sql that is to be used to insert data.
In other parts of the application, other classes that are identical, it works well. But for this one, instead of inserting the variable's value, it instead inserts the variable. e.g. "$this->firstname" as the value for the firstname
I tried to figure out whether POST values were being passed and when i echoed out the varaiables, the values were being passed correctly e.g. "$this->firstname" actually output the value i entered in the field for firstname.
So the problem must be with the sql and query. Can you help me figure out what the problem is?
function added_staff($inputArray)
{
if(isset($inputArray['Submit'])){
//pass array values to local variables
if(isset($inputArray['staff_role_id'])){$this->staff_role_id = $inputArray['staff_role_id'];}
if(isset($inputArray['firstname'])){$this->firstname = $inputArray['firstname'];}
if(isset($inputArray['middlename'])){$this->middlename = $inputArray['middlename'];}
if(isset($inputArray['surname'])){$this->surname = $inputArray['surname'];}
if(isset($inputArray['email'])){$this->email = $inputArray['email'];}
if(isset($inputArray['phone'])){$this->phone = $inputArray['phone'];}
if(isset($inputArray['create_date'])){$this->create_date = $inputArray['create_date'];}
if(isset($inputArray['status'])){$this->status = $inputArray['status'];}
$sql = "INSERT INTO staff(staff_role_id,firstname,middlename,surname,email,phone,create_date,status)
VALUES ('this->staff_role_id','this->firstname','this->middlename','this->surname','this->email','this->phone','this->create_date','this->status')";
$result = mysql_query($sql);
return $result;
}
}