我在使用下面的代码时遇到了问题,它给了我一个语法错误,我在手册或网上找不到任何关于它的内容。你对我如何让它运行有什么想法?
第一次尝试:
<?php
require("../dbpass.php"); $types = array('Buyer','Seller','Buyer / Seller','Investor');
$typeslist = implode ("','", $types);
$sql = "SELECT * FROM contacts WHERE contacttype IN ('$typeslist') AND status = 'New' ORDER BY date DESC";
$result = mysqli_query($mysqli,$sql) or die ("Error: ".mysqli_error($mysqli));
while ($row = mysqli_fetch_array($result)) {
第二次尝试(在“IN”之后放置一个“=”):
<?php
require("../dbpass.php");
$types = array('Buyer','Seller','Buyer / Seller','Investor');
$typeslist = implode ("','", $types);
$sql = "SELECT * FROM contacts WHERE contacttype = IN ('$typeslist') AND status = 'New' ORDER BY date DESC";
$result = mysqli_query($mysqli,$sql) or die ("Error: ".mysqli_error($mysqli));
while ($row = mysqli_fetch_array($result)) {
这是代码的其余部分:
$firstname = $row ['firstname'];
echo'.$firstname.';
}
?>
错误:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册以获取正确的语法,以便在 'IN ('Buyer','Seller','Buyer/Seller','Investor') AND status = 'New' ORDER BY da' 行附近使用1