Reputation: 1070
i was using the normal way to connect to the database and fetch data using mysql real escape string and i didn't face any erros but after moving to PDO I'm facing a problem which is adding \r\n to the end of the text in ckeditor here's the code
$home = mysql_real_escape_string($_REQUEST['home']);
$about = mysql_real_escape_string($_REQUEST['about']);
$id = '1';
$stmt = $db->prepare("update pages set home = :home, about = :about where ID = :id");
$stmt->bindParam(':home',$home);
$stmt->bindParam(':about',$about);
$stmt->bindParam(':id',$id);
$stmt->execute();
using this code to display data inside ckeditor
<textarea name="home" id="editor1" class="ckeditor"><?=$row['home']?></textarea><script>
CKEDITOR.replace('editor1');
</script>
I've added this line to ckeditor config file but the same result
config.FormatOutput = false ;
Upvotes: 0
Views: 556
Reputation: 45490
First of all PDO and mysql should not be mix.
Using pdo you don't need to escape anything, that's the whole point of prepared statement.
so just use the variables directly:
$home = $_REQUEST['home'];
$about = $_REQUEST['about'];
...
Upvotes: 1