I have a table[info] like this
+---+-------+---------------+
|id | cost | place |
+---+-------+---------------+
|1 | 2000 | Dhaka |
|2 | 1000 | Cox's Bazar |
+---+-------+---------------+
Now I'm using this query to show these data
$a_place = $_POST['place'];
query = "SELECT * FROM info WHERE place = '$a_place'";
It works fine when I am searching for Dhaka, but it is not working for Cox's Bazar. Maybe for this > '
Now what can I do? Please help!
$a_place = str_replace($_POST['place'],"'","''");
query = "SELECT * from info WHERE place = '".$a_place."'";
creating table and insert data
as you see the data ise like yours.
and If I select like mine the output is true
Maybe this will help for a start:
// prepare and bind
$a_place = $_POST['place'];
$stmt = $conn->prepare("SELECT country FROM info WHERE place = '?'");
$stmt->bind_param("s", $a_place);
$stmt->execute();
$stmt->store_result();
if($stmt->num_rows){
$stmt->bind_result($country);
$stmt->fetch();
$stmt->free_result();
echo $country;
};
?>
and see this post: Getting results of statement
(remeber that select * is bad practice)