0
$TableName = "interns";
if ($errors == 0)
    {
$SQLstring = "SELECT COUNT(*) FROM $TableName" . "WHERE email=$email";
$QueryResult = mysqli_query($DBConnect, $SQLstring);
    if ($QueryResult)
        {
            $Row = mysqli_fetch_row($QueryResult);
            if ($Row[0]>0)
                 {
                 echo "<p>The email address enterend (" . htmlentities($email) . ") is already registered.</p>\n";
                 ++$errors;
                 }
        }
    }

我在这里做错了什么,对我来说一切都很好。我有点晚了,也许我需要一双新鲜的眼睛。任何帮助将不胜感激。

4

1 回答 1

2

您缺少空格和引号,请更改:

"SELECT COUNT(*) FROM $TableName" . "WHERE email=$email";

至:

"SELECT COUNT(*) FROM $TableName" . " WHERE email='$email'";

或更简单(不需要字符串连接):

"SELECT COUNT(*) FROM $TableName WHERE email='$email'";

补充:
正如下面的 j_mcnally 建议的那样,$email为了防止可能的 sql-injection 攻击,最好转义

于 2013-09-28T03:26:36.013 回答