Hey there,
i am having a problem understanding how to get a method to update a class variable.
here is the class
class Field
{
var $customer, $name, $sensor;
function Field($customer, $name)
{
$this->customer = $customer;
$this->name = $name;
$query = mysql_query("SELECT `control_option`
FROM `Fields`
WHERE `Customer_ID` = '{$this->customer}'
AND `name` = '{$this->name}' ");
$row = mysql_fetch_row($query);
$this->control_option = $row[0];
}
function set_control_option($option)
{
$sensor = $this->sensor;
mysql_query("UPDATE `Fields` SET `control_option` = '{$option}'
WHERE `Sensor_ID` = '{$sensor}' ");
$this->control_option = $option;
}
}
then the class is called from another script
$field = new Field;
$control_option = '4'
print 'old control_option = '.$field->control_option.'<br>';
$field->set_control_option($control_option);
print 'new control_option = '.$field->control_option;
but, i am not getting anything out of it.
the database entry is empty, which happens if i send it an empty value in a query.
So the function is doing something. But i can't seem to get where i am going wrong here. The print statement
print 'new control_option = '.$field->control_option;
isn't giving me anything.
if you have read this far, thanks for your time, any idea what i am doing wrong?
thanks