选择查询,其中值中包含撇号[重复]

This question already has an answer here:

I need to use a select query but my code keeps crashing because some of the names have apostrophes in it. I pull all data into a table and half way through it just stops because it hits a apostrophe.

My select Query:

$query = mysqli_query($dbh,"select * FROM show_invoice where id_show='$get_id' and status='UNPAID' and scratch = 'Unscratched'and show_deleted != 'Deleted' ORDER BY 'class_no' ASC")

There are 3 columns that will possibly contain apostrophes. Any advice on how i can stop it from crashing.

</div>

You can use mysqli_real_escape_string.

So just do

$get_id = mysqli_real_escape_string($dbh,$get_id);

before running your query.

Note: You should really use prepared statements instead of own queries because of risk of SQL injection attacks.