【发布时间】:2015-07-29 14:14:59
【问题描述】:
在页面http://www.immocorbati.be/tehuur.php 上,过滤器功能无法正常工作。只有“Prijsklasse”(价格)有效。但是,如果您过滤“Gemeente”(区域)Boom,例如,它应该返回 1 个家,但它说没有找到。与“Type”工作室相同,应该返回 3 但不返回任何内容,“Slaapkamer”(卧室)3 slaapkamer 应该返回 1 个家,但同样没有显示。
我不明白为什么它在 localhost 上完美运行,而且它在网上运行一半一半,因为这意味着功能已达到。这是文件。也许有人有一些指示为什么会发生这种情况?它可能与数据库相关吗?但是后端等中的所有其他功能都可以正常工作。
class Pand
{
//DB settings - Don't worry these are correct
private $m_sHost = "??????";
private $m_sUser = "????????";
private $m_sPassword = "??????";
private $m_sDatabase = "????????";
public function GetToonPandenHuurFilter()
{
//de panden worden op pagina getoond volgens filter
if ($link = mysqli_connect($this->m_sHost, $this->m_sUser, $this->m_sPassword, $this->m_sDatabase))
{
$b = $_POST['typewoning'];
$p = $_POST['plaats'];
$s = $_POST['slaapkamers'];
$k = $_POST['prijsklasse'];
$sSql = "select * from tblpand WHERE PandVerkoopstype='Te huur' AND PandOnline='Ja'";
if ($b !== 'all') {
$sSql .= " AND PandBebouwing='" . mysql_real_escape_string($b) . "'";
}
if ($p !== 'all') {
$sSql .= " AND PandPostcodeGemeente='" . mysql_real_escape_string($p) . "'";
}
if ($s !== 'all') {
$sSql .= "AND PandSlaapkamers='" . mysql_real_escape_string($s) . "'";
}
if ($k == '0') {
$sSql .= "";
}
if ($k == '1') {
$sSql .= "AND PandPrijs <'" . 301 . "'";
}
if ($k == '2') {
$sSql .= "AND PandPrijs <'" . 501 . "'";
}
if ($k == '3') {
$sSql .= "AND PandPrijs <'" . 701 . "'";
}
if ($k == '4') {
$sSql .= "AND PandPrijs <'" . 701 . "'";
}
$rResult = mysqli_query($link, $sSql);
return $rResult;
}
else
{
// er kon geen connectie gelegd worden met de databank
throw new Exception('Ooh my, something terrible happened to the database connection');
}
mysqli_close($link);
}
}
我添加了错误报告,反馈说:
mysql_real_escape_string(): Access denied for user ''@'10.246.64.177'
(using password: NO) in /customers/e/a/b/immocorbati.be/httpd.www/classes/Pand.class.php on line 1086
第 1086 行是:
$sSql .= " AND PandBebouwing='" . mysql_real_escape_string($b) . "'";
【问题讨论】:
-
请进行更多调试。插入调试语句,
var_dump变量,缩小它开始失败的确切位置。在这方面,我们没有比您更好的位置了。 -
在测试代码时,您需要确保已启用 display_errors。如果服务器上出现问题,PHP 可能会详细说明。在您的脚本顶部
error_reporting(E_ALL); ini_set('display_errors', 1);然后在您部署到实时环境时禁用它。 -
好的,我就从这个开始。
-
Is it possibe that it is database related- 您正在查询数据库吗?然后确定这是可能的。这是什么$b$p,您可以使用多个字母,如果您将其命名为与您使用的密钥相同的名称,它会更容易阅读,即。$b = $_POST['typewoning']读起来更好,因为$typewoning = $_POST['typewoning']而这些 ` if ($k == '0') {` 应该是}else if ($k == '1') { -
感谢您迄今为止的帮助。如你所料,我当时处于恐慌状态。我添加了错误报告,反馈说:
mysql_real_escape_string(): Access denied for user ''@'10.246.64.177' (using password: NO) in /customers/e/a/b/immocorbati.be/httpd.www/classes/Pand.class.php on line 1086 –第 1086 行是:$sSql .= " AND PandBebouwing='" . mysql_real_escape_string($b) . "'";据我所知,连接数据有效,因为它也适用于其他功能并且以相同的方式链接到。