Please see the codes.
When I try:
function new_rate($item_selection,$service_selection,$rate)
{
try
{
$stmt = $this->conn->prepare("INSERT INTO rate(Item_Id,Service_Id,Rate)
VALUES(:_item, :_service, :_rate)");
$stmt->bindparam(":_item",$item_selection);
$stmt->bindparam(":_service",$service_selection);
$stmt->bindparam(":_rate",$rate);
$stmt->execute();
return $stmt;
}
catch(PDOException $ex)
{
echo $ex->getMessage();
}
}
if(new_rate(2,8,550)){
$msg = "Rate added successfully!";
$success_msg = "";
}
else
{
$msg = "sorry , Query could not execute...";
}
It works!
But when I try:
function update_query($table,$id,$update,$value)
{
try{
$stmt = $this->conn->prepare("UPDATE ".$table." SET ".$update."=:_value WHERE Id=:_id");
$stmt->bindparam(":_value",$value);
$stmt->bindparam(":_id",$id);
return $stmt->execute();
}
catch(PDOException $ex)
{
echo $ex->getMessage();
return 0;
}
}
if(update_query("rate",5,"Rate",25)){
$msg = "Rate updated successfully!";
$success_msg = "";
}
else
{
$msg = "sorry , Query could not execute...";
}
It displays: "Rate updated successfully!", but doesn't update the database. Where I am going wrong?
Please see the codes above?
Where I am going wrong?
Please see the codes above?