下面是我使用的PHP代碼:MYSQL_QUERY不工作
$query="select * from `myTable` where `email`='$email' limit 0,1";
if(empty($conn))
{
echo "not connected".PHP_EOL;
}
$result = mysql_query($query,$conn);
$row = mysql_fetch_array($result);
if(empty($row))
{
....
當查詢在phpMyAdmin執行,我獲得選擇單行。
但是,當我在php中執行代碼時,該行始終爲空。
對於我嘗試執行的其他幾個查詢也是如此。 mysql_query
總是失敗。
什麼可能是錯的?
你確認'$ email'有價值嗎? –
不轉義數據是非常危險的。使用['mysql_escape_string'](http://hk2.php.net/manual/en/function.mysql-escape-string.php)或['mysqli_real_escape_string'](http://hk2.php.net/manual/ en/mysqli.real-escape-string.php) –
您是否嘗試過在mysql_query上添加一些錯誤檢查? – andrewsi