문제

How can I add mysql_real_escape_string to this search query?

mysql_query("SELECT * FROM logs WHERE text LIKE '%$text%'");

$text comes from a POST-funktion. I have tried a lot of combinations with no success.

TRIED:

mysql_query("SELECT * FROM logs WHERE text LIKE '" . mysql_real_escape_string(%$text%) . "'");
mysql_query("SELECT * FROM logs WHERE text LIKE 'mysql_real_escape_string(%$text%)'");
도움이 되었습니까?

해결책

WHERE text LIKE '%".mysql_real_escape_string($text)."%'")
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top