Reputation: 3
I want to replace a string but I use PDO. Whatever I have tried is not working. Have you ever replaced a mysql string by using PDO connection?
Here is an example which is not working.
try
{
$image = $_POST['data1'];
$id= $_POST['data2'];
$insert = "UPDATE myTable SET images=REPLACE(images,':image','') where id = :id";
$insertStmt = $conn->prepare($insert);
$insertStmt->bindValue(":image", $image);
$insertStmt->bindValue(":id", $id);
$insertStmt->execute();
echo "success";
}
catch(PDOException $ex)
{
echo $ex->getMessage();
}
Upvotes: 0
Views: 471
Reputation: 111
write :image instead of ':image'
$insert = "UPDATE myTable SET images=REPLACE(images,:image,'') where id = :id";
Upvotes: 1