-2
當我嘗試創建註冊頁面時出現此錯誤。 警告:mysqli_real_query()預計2個參數,1給出 我嘗試使用的mysql_query(),但隨後說,這是過時的警告:mysqli_real_query()需要正好2個參數,給出1(註冊頁面)
這是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> </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導致我認爲的問題。
將DB連接變量傳遞給您的查詢。 'mysqli_real_query($ link,$ insert);' –
你可以解釋一下,因爲我是新手,我只是寫$ link – Ritsin
'bool mysqli_real_query(mysqli $ link,string $ query)' –