I'm using this code to check if a record exists or not:
$filename = $_FILES["file"]["name"]; /// FROM FORM
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1);
$bull = substr($filename, 0, strpos($filename, '.'));
$myQuery = "SELECT *
FROM $media
WHERE label='$bull' ";
$result = $dbh->prepare($myQuery);
$result->execute();
$cont = $result->rowCount();
if ($cont == 1) {
echo $bull.' Exists';
}
else {
echo $bull.' Does Not Exists';
}
Which works fine except if there's an apostrophes in the record. Then it returns that it doesn't exist. So if "Hello There" exists, it says so. But if "Where's Hello" exists, it says it doesn't.