-1

我有这个查询

 $DB->query("SELECT id FROM tfilter WHERE '". $Properties['Title'] ."' LIKE CONCAT('%', filter, '%')");

我需要这样做,以便脚本在得到结果时死亡,现在我有这个:

    if($DB->record_count() != 0) {
    $Err = '<b>This cant be uploaded</b>';
    include(SERVER_ROOT . '/sections/upload/upload.php');
    die();

if($DB->record_count() != 0) {

这应该是别的吗?因为它不会死,即使我知道它有结果

这个查询在 phpscript 中看起来像这样。它是更大网站的一部分

$DB->query("SELECT id FROM tfilter WHERE '". $Properties['Title'] ."' LIKE CONCAT('%', filter, '%')");
 if($DB->record_count() != 0) {
 $Err = '<b>This cant be uploaded</b>';
 include(SERVER_ROOT . '/sections/upload/upload.php');
 die();

 $Properties['Title'] = String from the upload script that contains the titel.
 $DB is the call til mysql
 filter = the row in mysql
 tfilter = the database name

我需要什么:

我需要 php 在 FILTER 行中的表格 TFILTER 中搜索与 $Properties['Title'] 的匹配项,如果找到任何匹配项则 DIE。如果字符串:The.White.Tiger。存在于 FILTER 行中,og $Properties['Title'] 包含 The.White.Tiger.In.The.Yard,php 应该死掉。

4

2 回答 2

0

我认为您的查询需要是(用反引号替换单$Properties['Title']引号):

$DB->query("SELECT id FROM filter WHERE `". $Properties['Title'] ."` LIKE CONCAT('%', filter, '%')");

此外,您不需要使用该concat函数来添加和附加%字符,您可以简单地使用它,如下所示:

$DB->query("SELECT id FROM filter WHERE `". $Properties['Title'] ."` LIKE '%{$filter}%'");
于 2013-08-18T19:09:57.833 回答
0

你能不使用 rowCount() 吗?

所以它应该看起来像这样:

$stmt = $DB->query("SELECT id FROM tfilter WHERE '". $Properties['Title'] ."' LIKE CONCAT('%', filter, '%')");
$numrows=$stmt->rowCount();

$error= $stmt->errorInfo();
echo $error[2];

if($numrows) {
$Err = '<b>This cant be uploaded</b>';
include(SERVER_ROOT . '/sections/upload/upload.php');
die();
于 2013-08-18T19:12:26.943 回答