You can create a single quote using chr(39)
and append it to the string. You should also escape the contents of $gname
mysqli_query($con,"SELECT * FROM wp_games WHERE name = " . chr(39) . mysqli_real_escape_string($con, $gname) . chr(39));
2
solved PHP quote within 2 different quotes [closed]