try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "UPDATE table_name SET name=:name where id=1";
$stmt = $conn->prepare($sql);
$stmt->execute(['name'=>'dsf"fsd"fds']);
}catch(PDOException $e){
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
with this code name
is saved as dsf"e;fsd"e;fds
in mysql database
with laravel if I save name
it will save as dsf"fsd"fds
only.
why php saves it differently and how to save it as it is using php pdo. please share the code.