Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 两个未定义变量where和search的注意事项_Php_Search_Where - Fatal编程技术网

Php 两个未定义变量where和search的注意事项

Php 两个未定义变量where和search的注意事项,php,search,where,Php,Search,Where,我所有的页面上都有这两个通知 我如何解决这些问题 刚刚添加了输入类型 Notice: Undefined variable: where Notice: Undefined variable: search 此部分需要else语句或$,其中需要有默认值。未设置$search时,将永远不会设置$where if (isset($search)) { $where = "WHERE `first` LIKE '%$search%' OR `second` LIKE '%$sear

我所有的页面上都有这两个通知

我如何解决这些问题

刚刚添加了输入类型

Notice: Undefined variable: where
Notice: Undefined variable: search

此部分需要else语句或
$,其中
需要有默认值。未设置
$search
时,将永远不会设置
$where

if (isset($search)) {    
    $where = "WHERE `first` LIKE '%$search%' OR `second` LIKE '%$search%'";
}

这是一段连续的代码吗?我的意思是,
/
是否涵盖了缺失的代码?
$start
$view
$query
是否在同一范围内?
$search
变量来自何处?它是在您的代码中的其他地方设置的,还是您正在使用
register\u globals
或其他什么?是的,您是对的。我现在添加它。Thnx!是的,这修复了$where通知。我看不到您的代码中会显示其他通知的任何部分。通知应该给出生成它的代码行-你确定这部分在你的问题中吗?在1页上,此解决方案不起作用,如果我转到?子页->警告:mysql\u fetch\u object():提供的参数在第999行中不是有效的mysql结果资源警告:mysql\u num\u rows()期望参数1是资源,布尔给定这不是上述错误的解决方案,而是发布的警告。通常,PHP中的警告或通知问题很容易解决,因为您通常会得到损坏的行和错误的解释,这使得调试变得简单可行
if (isset($search)) {    
    $where = "WHERE `first` LIKE '%$search%' OR `second` LIKE '%$search%'";
}
$where = "";
if (isset($search)) {    
    $where = "WHERE `first` LIKE '%$search%' OR `second` LIKE '%$search%'";
}