-4
我已經在這裏搜索這個相同的問題被問及,發現很多答案,並沒有解決我的錯誤,通常只是創建更多:P 這裏是滿的錯誤警告:mysqli_error()期望只有1個參數,0給出
Warning: mysqli_error() expects exactly 1 parameter, 0 given in F:\Jacob's Project rehash\register.php on line 54.
,這裏是整個PHP頁面,它棲息於:
<!DOCTYPE html> <html> <head> <title>Membership Confirmation</title> <script type='text/javascript' src='gen_validatorv31.js'></script> </head> <body> <h1></h1> <p>Thank for your membership support!</p> <br> <?php //assign connection details to PHP variables $servername="localhost"; $username="root"; $password=""; $database="bryanbook"; //connect to the database server and select Bryanbook database $link=mysqli_connect($servername,$username,$password,$database); //check for successful connection if (mysqli_connect_error()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } //assign values submitted by HTML form to PHP variables $email = $_POST['email']; $firstname = $_POST['firstname']; $surname = $_POST['surname']; $addressline1 = $_POST['addressline1']; $password = $_POST['password']; $towncity = $_POST['towncity']; $postcode = $_POST['postcode']; $favouritecolour = $_POST['favouritecolour']; $likes = $_POST['likes']; $dislikes = $_POST['dislikes']; //create query to add member details to database $query = "INSERT INTO users (email,password,firstname,surname,`address line 1`,town/city,postcode,`fave colour`,likes,dislikes) VALUES ('$email','$password','$firstname','$surname','$addressline1','$towncity','$postcode','$favouritecolour','$likes','$dislikes')"; //execute SQL query to add details to the member table $data = mysqli_query($link, $query)or die(mysqli_error()); <------- Line 54 //check that query has been successful if($data) { //display message to notify user that details have been added echo "Your registration has been successful"; } //close server connection mysqli_close($link); //exit PHP ?> <br> <p><a href="Home Page.html">Click here to return to the Home Page</a></p> </body> </html>
相當自我解釋,如果你確實讀取錯誤。閱讀[documentation](http://php.net/manual/en/mysqli.error.php) – aynber
您需要在mysqli_connect_error函數中發送參數$ link。 if(mysqli_connect_error($ link)){.... –