Rain - 2021-11-06 21:22:02
Hi,
Can someone explain me in simple terms how to deal with apostrophe issues within a select query php.
<?php
$sql = "SELECT * FROM $County WHERE `Townland`='$Townland'";
if($result = mysqli_query($link, $sql)){
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_array($result)){
echo '<table width="90%" border="0">';
echo '<tr>';
echo '<td width="18%">Townland</td>';
echo '<td width="">'.$row["Townland"].'</td>';
echo '</tr>';
echo '<tr>';
echo '<td width="18%">Qualifier</td>';
echo '<td width="">'.$row["Qualifier"].'</td>';
echo '</tr>';
}
mysqli_free_result($result);
} else{
echo "Nothing selected yet!";
}
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
?>
I got this error message: ERROR: Could not able to execute SELECT * FROM Essex WHERE `Townland`='St. John's Court'. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's Court, Kilmore Road'' at line 1
Thanks in advance,
Rain