PHP/PDO:SQl查找包含字符串值的行
我试图请求查找包含特定字符串值的行 以下是我的代码摘录:PHP/PDO:SQl查找包含字符串值的行,php,mysql,sql,pdo,Php,Mysql,Sql,Pdo,我试图请求查找包含特定字符串值的行 以下是我的代码摘录: // Getting motscles value $motscles = $_POST['motscles']; // Prepare a second SQL request to get all annonces posted by the user $result2=$connexion->prepare("select * from annonces where titre
// Getting motscles value
$motscles = $_POST['motscles'];
// Prepare a second SQL request to get all annonces posted by the user
$result2=$connexion->prepare("select * from annonces where titre LIKE = '%".$motscles."%' ");
我没有结果,我认为我的要求不好
LIKE =
那是不对的,应该是-
LIKE '%".$motscles."%'
在这里检查类似通配符的用法
此外
@abhik的
回答,如果你准备好了,就要做好准备
$stmt=$connexion->prepare('select * from annonces where titre LIKE ?');
$result2=$stmt->execute(array('%'.$motscles.'%'));
删除LIKE关键字后的等号;这是无效的语法。哦,你现在可以使用。你似乎有能力使用,那么就这样做,否则后果自负。