dongzhao8233 2017-03-22 12:49
浏览 189
已采纳

警告: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>
<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>
</div>
  • 写回答

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 矩阵加法的规则是两个矩阵中对应位置的数的绝对值进行加和
  • ¥15 活动选择题。最多可以参加几个项目?
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)
  • ¥20 怎么在stm32门禁成品上增加查询记录功能
  • ¥15 Source insight编写代码后使用CCS5.2版本import之后,代码跳到注释行里面
  • ¥50 NT4.0系统 STOP:0X0000007B
  • ¥15 想问一下stata17中这段代码哪里有问题呀