我没有得到它,我发现此代码中没有错误,但存在此错误
Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in /home/u907609640/public_html/zmienione/index.php on line 152
Warning: mysqli_query() expects at least 2 parameters, 1 given in /home/u907609640/public_html/zmienione/index.php on line 162
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in /home/u907609640/public_html/zmienione/index.php on line 162
代码index.php
$login = mysqli_real_escape_string($_POST['login']);
$password = mysqli_real_escape_string($_POST['password']);
$password = md5($password);
$sql = mysqli_num_rows(mysqli_query("SELECT * FROM `user` WHERE `login` = '$login' AND `password` = '$password'"));
连接代码
<?php
$dbhost = '';
$dblogin = '';
$dbpass = '';
$dbselect = '';
$conn = mysqli_connect($dbhost, $dblogin, $dbpass, $dbselect);
mysql_connect($dbhost,$dblogin,$dbpass);
mysql_select_db($dbselect) or die("Some text");
mysql_query("SET CHARACTER SET UTF8");
mysqli_connect($dbhost,$dblogin,$dbpass);
mysqli_select_db($dbselect) or die("Some text");
mysqli_real_escape_string($conn);
mysqli_query($conn, $sql);
?>
问题是什么?我是新手,请在我的例子中解释一下。我测试了其他答案,但它没有用。
答案 0 :(得分:0)
对于mysql_real_escape_string,您必须传递两个参数:connexion,然后是您要检查的字符串。
mysqli_query错误的同样问题,你必须传递connexion($ con)和另一个参数。
我认为你试图使用面向对象的函数而不是程序函数。
检查php.net上所有这些功能的手册!