mysqli_query(): Empty query in if(mysqli_query($link, $result)){
Catchable fatal error: Object of class mysqli_result could not be converted to string in line echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
可我知道這裏有什麼問題的錯誤?
<?php
$link = mysqli_connect("localhost", "root", "", "databasename") or die("could not connect to mysql");
$email = $_SESSION['USEREMAIL'];
$password = $_SESSION['USERPASS'];
$sql= mysqli_query($link, "SELECT * FROM admin WHERE email='$email' and password ='$password' ");
if (isset($_POST["submit"])) {
$test = mysqli_real_escape_string($link, $_POST['test']);
$result = mysqli_query($link,"UPDATE admin SET test='$test' WHERE email='$email'");
if(mysqli_query($link, $result)){
echo "Updated successfully.";
} else {
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
}
while ($record = mysqli_fetch_array($sql)) {
$test = $record['test'];
}
mysqli_close($link);
?>
http://php.net/manual/en/mysqli.query.php –
'$ result'是*已經是'mysqli_query()'你需要改變'如果(mysqli_query($連接,$結果)){'''if like($ result)''' –
**''不要存儲純文本密碼!**請使用PHP的[內置函數](http://jayblanchard.net/proper_password_hashing_with_PHP.html)處理密碼安全。如果您使用的PHP版本低於5.5,則可以使用'password_hash()'[兼容包](https://github.com/ircmaxell/password_compat)。確保你*** [不要越獄密碼](http://stackoverflow.com/q/36628418/1011527)***或在哈希之前使用其他任何清理機制。這樣做*更改密碼並導致不必要的附加編碼。 –