2017-03-22 12:49
浏览 160

警告:mysqli_error()只需要1个参数,给定[重复] 0

This question already has an answer here:

I have searched on here for this same question being asked and found many answers that did not fix my error at all and usually just created more :P Here is the full error

Warning: mysqli_error() expects exactly 1 parameter, 0 given in F:\Jacob's Project rehashegister.php on line 54.

and here is the entire PHP page that it inhabits:

 <!DOCTYPE html>


<title>Membership Confirmation</title>
    <script type='text/javascript' src='gen_validatorv31.js'></script>

<p>Thank for your membership support!</p>



//assign connection details to PHP variables

//connect to the database server and select Bryanbook 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
  //display message to notify user that details have been added
  echo "Your registration has been successful";

//close server connection

//exit PHP

<p><a href="Home Page.html">Click here to return to the Home Page</a></p>

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dragonsun2005 2017-03-22 12:55

    change $data = mysqli_query($link, $query)or die(mysqli_error()); <------- Line 54

    to (simply pass the $link connection to the mysqli_error() function)

    $data = mysqli_query($link, $query)or die(mysqli_error($link)); <------- Line 54

    解决 无用
    打赏 举报

相关推荐 更多相似问题