Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steveosoule/291959634ce3655eeea636e21efe8396 to your computer and use it in GitHub Desktop.
Save steveosoule/291959634ce3655eeea636e21efe8396 to your computer and use it in GitHub Desktop.
Replace Broken/Invalid Characters (Latin ISO-8859-1 to UTF-8 charset)
<?php
// Load Posts
$query = $dbh->query("SELECT * FROM `Posts`");
$posts = $query->fetchAll();
// Update Posts
foreach($posts as $post)
{
$query = $dbh->prepare("UPDATE `Posts` SET content = :content WHERE id = :id");
$query->bindParam(':content', utf8_encode($post['content']));
$query->bindParam(':id', $post['id']);
$query->execute($params);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment