Can anyone see the problem with this function

A

Anonymous

Guest
Does anyone see the problem with this function?
It is supposed to check whether a shipping value has been set. If it has not, it writes a shipping value to the shipping table in the form session, shipping value and quantity.

If the shipping has been set before it updates the shipping value.
There is only one value per session.

However, the function always writes to the table as a new row. It does not care if the same session already exists.

Function below can anyone see the problem?

:?
function set_shipping($ship) {
$qty = $this->check_ship($quant);
if($qty == 0) {
$query = "INSERT INTO shipping (session, ship, quant) VALUES ('".$this->ship_id."','$ship', '1')";
mysql_query($query, $this->dblink);
}
else {
$query = "UPDATE ".$this->ship_table . " SET ship ='$ship' WHERE session='".$this->ship_id."'";
mysql_query($query, $this->dblink);
}
return true;
}

function check_ship($quant) {

$query = "SELECT quant FROM ".$this->ship_table. " WHERE session='".$this->ship_id."'";
$result = mysql_query($query, $this->dblink);
if(!$result) {
return 0;
}
}
 
Back
Top