I'm brand new to stackoverflow and my PDO skills are limited, so I'm asking for help from someone who knows more than I do.
I use PDO prepared statements almost exclusively and for one particular app I've been fetching an entire string, modifying, then updating it.
What I would like to do is update a substring based on a positional value sent along with the modified string.
For example, if my string is "abcdefg" I would like to be able to send the string "z" along with the integer 2 which would replace "b" with "z" so the stored string would now read "azcdefg".
The following code is not correct, I know, but it shows the general outline of what I'm trying to accomplish:
$user = $_POST['user'];
$newstring = $_POST['newstring'];
$integer = $_POST['integer'];
$sql = "UPDATE table SET string=? WHERE user=?";
$stmt= $pdo->prepare($sql);
$stmt->execute( [substring $integer] $newstring, $user]);
Again, the code is totally not right, at least with respect to the substring line, because I have no idea how to tell it to update just a specific substring position with a new string.