我一直收到这个错误:
PHP错误消息
解析错误:语法错误,意外T_ENCAPSED_AND_WHITESPACE,期待T_STRING或T_VARIABLE或T_NUM_STRING 第4行/home/a6941725/public_html/php/usersystem/signup.php
以下是代码:
if (mysql_query("SELECT * FROM Main WHERE username LIKE $_POST['username']"); !== "$_POST['username']") {
$username = $_POST['username'];
}
我通常擅长php,但我无法弄清楚它为什么不起作用!
答案 0 :(得分:-1)
你应该尝试一下,
$query = sprintf("SELECT * FROM Main WHERE username LIKE '%s'",
mysql_real_escape_string($_POST['username']);
$result = mysql_query($query);// gives result
while ($row = mysql_fetch_array($result)) {
if ($row['username'] !== $_POST['username']) { // remove quotes from post field
$username = $_POST['username'];
break;// if both are not same then break
}
}