MySQL:SEARCH查询中的mysql_real_escape_string

时间:2013-08-28 13:02:28

标签: mysql sql search mysql-real-escape-string

如何在此搜索查询中添加mysql_real_escape_string

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

$text来自POST-funktion。我尝试了很多组合但没有成功。

尝试:

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%)'");

1 个答案:

答案 0 :(得分:1)

WHERE text LIKE '%".mysql_real_escape_string($text)."%'")