0
我得到這個錯誤,當我在我的查詢添加LIKE
如何在此查詢語句中添加LIKE查詢而不是相等?
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 '' OR agent_ip = 'Counter' OR port = 'Counter' OR 0home_ip_por' at line 45
我的代碼是:
'.($search_field ?" AND home_id = '$search_field' OR user_id_main = '$search_field' OR home_path = '$search_field'
OR home_name = '$search_field'
OR user_id_main IN (SELECT `user_id` FROM `".$this->table_prefix."users` WHERE users_login = '$search_field')
OR user_id = '$search_field'
OR user_id IN (SELECT `user_id` FROM `".$this->table_prefix."users` WHERE users_login = '$search_field')
OR agent_ip = '$search_field' OR port = '$search_field'
" : '').
我需要在這條線來代替=
到LIKE
OR home_name = '$search_field'
可以嗎共享執行的查詢? – farhadamjady
使用準備好的語句,否則即使您轉義變量,您也容易受到SQL注入的攻擊。 – Enstage