0

我不断收到此错误:

PHP Parse 错误:语法错误,意外的 T_STRING

对于这一行:

if($email_addr == "") /* If real email not found, return FALSE*/

我不知道哪里出了问题,尝试了很多东西,研究了两天,没有更正。我想知道是否其他人可以看到我做错了什么。为什么我会收到此错误?谢谢你。(功能如下)

    function searchRecipient() // function to search the database for the real email
{
    global $MessageSentToMailbox; // bring in the alias email
    $email_addr = mysql_query("SELECT email FROM tbl WHERE source='$MessageSentToMailbox'"); // temp store of the real email
    $row = mysql_fetch_assoc($email_addr); //making temp store of data for use in program
    if($email_addr == "") /* If real email not found, return FALSE*/
    {
        return FALSE;
    }
    else  /* Else, return find the person's name and return both in an array */
    {
        $query = "SELECT * FROM tbl WHERE email = '$email_addr'"; // pulling in the row where the emails match
        $results = mysql_query($query, $email_addr); // temp store of both queries from this function
        $row = mysql_fetch_assoc($results); //making temp store of data for use in program
        $name = $row['author'];  // taking the author data and naming its variable
        return array($name, $email_addr);  // this is the name and the real email address to be used in function call
    }
}
4

2 回答 2

1

您正在将资源与字符串进行比较。

你真正想做的是:

if ($row['email']== "")

或者,更好的是:

if (empty($row['email']))
于 2012-05-04T18:34:27.490 回答
0
if($row['email']== "") /* If real email not found, return FALSE*/
    {
        return FALSE;
    }
于 2012-05-04T18:34:27.150 回答