我正在寫一個簡單的程序在PHP中,要求用戶登錄。我有一個工作代碼,但每當進入一個錯誤的用戶名或密碼,我得到了,說以下內容的異常:登錄腳本在PHP中我的MYSQL顯示已棄用警告
推薦使用:mysql_connect()函數:mysql擴展已被棄用,並將在將來被移除:使用mysqli或PDO,而不是在C:\ wamp \ www \ Directory \ login.php在線67
我有的腳本運行良好,但我只需要擺脫此警告消息。 以下是我的php代碼。
<?php
$username = $_POST['username'];
$password = $_POST['password'];
// Connect to the database
$con = mysql_connect('localhost', 'root', '');
// Make sure we connected succesfully
if (!$con) {
die('Connection Failed' . mysql_error());
}
// Select the database to use
mysql_select_db("Garden", $con);
$q = mysql_query("select * from register where username='" . $username . "' and password='" . $password . "' ") or die(mysql_error());
$res = mysql_fetch_row($q);
if ($res) {
header('location:home.php');
} else {
echo 'Error. The Username or Password that you entered is invalid.';
}
?>
我不知道如果即時通訊使用的東西。這是我第一次使用php。拜託我需要你的幫忙。謝謝。
請勿使用折舊功能,請使用mysqli - http://php.net/manual/en/book.mysqli.php或PDO - http://php.net/manual/en/book.pdo .php – andyroo 2014-10-01 10:53:50