아래 오류가 나타납니다. MySQL과 PHP를 사용하여 키워드를 검색하여 데이터베이스에서 값을 가져와야합니다.PHP와 MySQL을 사용하여 데이터베이스에서 데이터를 가져 오는 동안 Sql 구문 오류가 발생합니다.
Error:
1064 - 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 'Sheela'%' and b.quadrant='2' and b.status=1 and b.city !=0 ORDER BY b.member_id ' at line 1
내 쿼리는 아래에 나와 있습니다.
$searchKey=$_GET['searchKey'];
$day_id=$_GET['day_id'];
$quad_id=explode(",",$_GET['quad_id']);
$keyword = '%'.$searchKey.'%';
"SELECT b.member_id,b.rest_name,b.proviance,b.city,b.postal,b.address,b.country,b.person,b.mobile,b.url,b.status,b.premium,b.image,b.business_phone_no,b.email,b.multiple_image,b.quadrant,ct.city_id,ct.city_name FROM db_restaurant_basic AS b INNER JOIN db_city AS ct ON b.city=ct.city_id WHERE b.rest_name LIKE '".$keyword."' and b.quadrant='".$quad_id[$i]."' and b.status=1 and b.city !=0 ORDER BY b.member_id DESC.
이 오류를 해결하는 데 도움을주십시오.
내가 같이가 'WHERE b.rest_name LIKE ' ". $ keyword."''. – subhra
@subhra하지만 코드에는 표시되지 않습니다. 당신이 보인 경우에, sheela는 문자열이 아니라 변수입니다 – Jens
@ jens : 업데이트 된 게시물을 확인하십시오. – subhra