我覺得我現在真的很接近 - 沒有更多令人討厭的橙箱錯誤 - 我現在唯一可以看到的唯一問題是,一旦我更新表(在用PHP插入用戶更新到SQL
之後$qry = "UPDATE 'members' ('employer', 'flat') WHERE login='$login_name' VALUES ". " ('$employ', $address')";
)我得到消息"No rows updated"
回顯屏幕!
任何想法是什麼問題? 謝謝。
<?php
//Start session
session_start();
$_SESSION['SESS_LOGIN'];
//Include database connection details
require_once('config.php');
//Array to store validation errors
$errmsg_arr = array();
//Validation error flag
$errflag = false;
//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database");
}
//Function to sanitize values received from the form. Prevents SQL injection
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
//Sanitize the POST values
$employ = clean($_POST['employer']);
$address = clean($_POST['flat']);
?>
<?Php
//Insert employer and address into database row for logged in user.
$login_name = $_POST['login_name'] ;
$qry = "UPDATE 'members' ('employer', 'flat') WHERE login='$login_name' VALUES ". " ('$employ', $address')" ;
$result = @mysql_query($link, $qry);
//Check whether the query was successful or not
if(!$result) {
echo "No rows updated";
exit();
}else {
echo "Success";
}
?>
**對mysql_ *函數沒有更多的支持**,它們是[**正式棄用**](https://wiki.php .net/rfc/mysql_deprecation),**不再維護**,並將[**刪除**](http://php.net/manual/en/function.mysql-connect.php#warning)未來。您應該使用[PDO](http://php.net/pdo)或[MySQLi](http://php.net/msqli)更新您的代碼,以確保您的項目在未來的功能 – Schleis
只需預先安裝,通過貶低mysql *函數的註釋,他可以自由使用他希望的任何功能。請不要發表重複的評論。 – imulsion
@imulsion謝謝!這太讓人討厭了。誰在乎他是否在使用mysql_',這與問題完全無關。 – sgroves