MySQL LIKE + php sprintf

前端 未结 5 2275
陌清茗
陌清茗 2021-02-13 13:34
$test = sprintf(\"SELECT * FROM `table` WHERE `text` LIKE \'%%s%\'\", mysql_real_escape_string(\'test\'));

echo $test;

output:

SELECT          


        
5条回答
  •  春和景丽
    2021-02-13 13:36

    $test = "SELECT * FROM `table` WHERE `text` LIKE '%s%'" . mysql_real_escape_string('test');
    
    echo $test;
    

提交回复
热议问题