I need help with escaping a single quote. I have checked a lot of material out there, but I am not that savvy enough to make use of it. My PHP code is below.
<?php
$db = new PDO("mysql:host=localhost;dbname=tool", 'root', 'password');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1);
$rne = file_get_contents('/path/export.txt');
$sql = "
LOAD DATA INFILE '/path/UCBTexport.txt'INTO TABLE tool_tbl FIELDS TERMINATED BY ',' ( Bug_ID, Date_Tool_Ran, Headline, Submitted_By, Create_Modify_Date, Severity, Status );
UPDATE `tool_tbl` SET `Release_Notes`= '$rne' WHERE id = LAST_INSERT_ID()
";
$stmt = $db->prepare($sql);
$stmt->execute();
$i = 0;
do {
$i++;
}
while ($stmt->nextRowset())
;
$error = $stmt->errorInfo();
if ($error[0] != "00000")
{
echo "Query $i failed: " . $error[2];
}
else
{
echo "inserted Successfully";
}
die();
Both my queries have text that can occasionally contain all types of special characters. How do I use the mysql_real_escape_string within this code to escape special characters?