我嘗試使php登錄,但我得到這個錯誤:Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given,
我做錯了什麼?警告:mysqli_real_escape_string()需要2個參數,1給出...我做錯了什麼?
register.php
<!doctype html>
<html lang"fi">
<head>
<link rel="icon" type='image/png' href='images/logo.png'>
<title>
asd
</title>
<link href="css/styles.css" type="text/css" rel="stylesheet">
</head>
<body>
<!--reg alkaa-->
<form action="register.php" method="post">
<p><input type="text" name="username" placeholder="Username">
<p><input type="email" name="email" placeholder="Email">
<p><input type="password" name="pass" placeholder="Password">
<p><input type="password" name="pass1" placeholder="Password">
<p><input type="submit" name="submit" value="Register">
</form>
<?php
if(isset($_POST['submit']))
{
$username = mysqli_real_escape_string($_POST['username']);
$pass = mysqli_real_escape_string($_POST['pass']);
$pass1 = mysqli_real_escape_string($_POST['pass1']);
$email = mysqli_real_escape_string($_POST['email']);
if($username && $pass && $pass1 && $email)
{
if($pass==$pass1)
{
$connect = mysql_connect("mysql13.000webhost.com","a2955851_SW","ASPIREX1930");
mysql_select_db("a2955851_SW");
$query = mysql_query("INSERT INTO users VALUES('$username','$pass','$email');");
echo "You have been registered.";
}
else
{
echo "Password must match.";
}
}
else
{
echo "All fields are required.";
}
}
?>
<!--reg end-->
<Center>
<a href="index.php">
<h1>
asd
</h1>
</center>
<div id="main">
<h3>
<div class="menu"> <a href="index.php">Etusivu</a> •
<a </div>
</h3>
</div>
<div class="jonne">
</div>
<script src="javascript/jquery.js"></script>
</body>
</html>
我使用000webhost的這第一次,當我在網上使用MySQL數據庫。
我不這不意味着粗魯,但你讀過錯誤嗎? – sevenseacat 2014-09-03 05:42:58
是的,但我沒有很好的英語技能 – user3774980 2014-09-03 14:57:36
不要分享你的連接細節,如數據庫連接設置... – candlejack 2017-02-27 05:06:32