0

I am trying to get value with ajax and the values are in form of string, but the problem is when I'm trying to use a condition of if value empty then return this or else do that

My code is

if (empty($title) || empty($thumbnail) || empty($link))
{
    echo "404";
}
else
{
    some custom line
}

My problem is that a 404 is returned even if the value of any one of them (title, thumbnail, or link) is not empty. Can any one point me where I am wrong?

Here's how I am getting value from ajax:

$title = mysql_real_escape_string($_REQUEST['title']);
$thumbnail = mysql_real_escape_string($_REQUEST['thumbnail']);
$link = mysql_real_escape_string($_REQUEST['link']);
4

1 回答 1

0

首先我建议你不要使用空,因为它有一些特定的行为。

第二:我不明白你为什么使用mysql_real_escape_string,你必须查询数据库?

此外,我猜您(正如@havelock 指出的那样)如果没有设置任何值,则想要获得 404。

我是为了这个:

if($title && $thumbnail && $link){
    //all fine..
}
else 404
于 2012-06-24T14:45:16.617 回答