警告:mysqli_real_query()需要2个参数,1个给定(Register Page)

时间:2014-07-25 00:27:59

标签: php mysql mysqli registration

当我尝试创建注册页面时,出现了此错误。 警告:mysqli_real_query()需要2个参数,给定1个 我尝试使用mysql_query(),但后来说它已经过时了

这是index.php:

<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="content-type" content="text/html" />
    <title>Untitled Page</title>
</head>
<body>


<form method="POST" action="reg.php" >


<table>
<tr>
    <td>Username:</td>
    <td><input type="text" name="username"/> </td>
</tr>
<tr>
    <td>Email:</td>
    <td><input type="email" name="email"/> </td>
</tr>
<tr>
    <td>First Name:</td>
    <td><input type="text" name="fname"/> </td>
</tr>
<tr>
    <td>Last Name:</td>
    <td><input type="text" name="lname"/> </td>
</tr>
<tr>
    <td>Password</td>
    <td><input type="password" name="pass"/> </td>
</tr>
<tr>
    <td>&nbsp</td>
    <td><input type="submit" name="submit" value="Submit" /> </td>
</tr>
</table>


</form>




</body>
</html>

这是我的config.php:

<?php
$link = mysqli_connect('localhost', 'root', '', 'reg')



?>

和我的reg.php:

<?php
include"Config.php";

$username = $_POST['username'];
$email = $_POST['email'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$password = md5($_POST['pass']);

$insert = 'INSERT into users(username, email, fname, lname, pass) VALUES("'.$username.'", "'.$email.'", "'.$fname.'", "'.$lname.'", "'.$password.'")';

mysqli_real_query($insert);
?>

reg.php正在引发我认为的问题。

1 个答案:

答案 0 :(得分:1)

如错误所示,您应该在mysqli_real_query函数中再添加一个参数。这个参数是你的mysqli $链接。