我正在尝试使用此代码创建一个小型搜索功能来查看数据库:
$searchQ = 'Li';
$query = $connDB->prepare('SELECT * FROM topic WHERE topic_name LIKE '."':keywords'");
$query->bindValue('keywords', '%' . $searchQ . '%');
$query->execute();
if (!$query->rowCount() == 0) {
while ($results = $query->fetch()) {
echo $results['topic_name'] . "<br />\n";
}
} else {
echo 'Nothing found';
}
Run Code Online (Sandbox Code Playgroud)
这将返回数据库中的所有项目,而不仅仅是相似的项目,
然后我运行了这个SQL查询:
SELECT * FROM topic WHERE topic_name LIKE '%Li%';
Run Code Online (Sandbox Code Playgroud)
这按预期运行并返回所需的结果.
我错过了什么?
与Windows不同,我在Linux中使用"mailtodisk"PHP选项时遇到了麻烦.看起来它甚至不存在.
在"php.ini"中,在邮件部分中,没有对它的引用:
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP=localhost
; http://php.net/smtp-port
smtp_port=25
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = me@example.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path =
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters = …Run Code Online (Sandbox Code Playgroud)