gpt4 book ai didi

php - 错误: Deprecated: Function mysql() is deprecated

转载 作者:行者123 更新时间:2023-11-29 19:53:54 25 4
gpt4 key购买 nike

Deprecated: Function mysql() is deprecated in /home/u624273934/public_html/ecommerce/admin_area/login.php on line 39

Warning: mysql() expects parameter 1 to be string, object given in /home/u624273934/public_html/ecommerce/admin_area/login.php on line 39

Warning: mysql_result() expects at least 2 parameters, 1 given in /home/u624273934/public_html/ecommerce/admin_area/login.php on line 41

代码是这样的:

 <?php 
session_start();

?>
<!DOCTYPE>
<html>
<head>
<title>Login Form</title>
<link rel="stylesheet" href="styles/login_style.css" media="all" />

</head>
<body>
<div class="login">
<h2 style="color:white; text-align:center;"><?php echo @$_GET['not_admin']; ?></h2>

<h2 style="color:white; text-align:center;"><?php echo @$_GET['logged_out']; ?></h2>

<h1>Admin Login</h1>
<form method="post" action="login.php">
<input type="text" name="user_email" placeholder="Email" required="required" />
<input type="password" name="user_pass" placeholder="Password" required="required" />
<button type="submit" class="btn btn-primary btn-block btn-large" name="login">Login</button>
</form>
</div>


</body>
</html>
<?php

if(isset($_POST['login'])){

$user_email = $_POST['user_email'];
$user_pass = $_POST['user_pass'];

$sel_c = "select * from admins where user_pass='$user_pass' AND user_email='$user_email'";

$run_c = mysql($con, $sel_c);

$check_customer = mysql_result($run_c);

if($check_customer==0){

echo "<script>alert('Password or email is incorrect, plz try again!')</script>";
exit();
}
$ip = getIp();

$sel_cart = "select * from cart where ip_add='$ip'";

$run_cart = mysqli_query($con, $sel_cart);

$check_cart = mysqli_num_rows($run_cart);

if($check_customer>0 AND $check_cart==0){

$_SESSION['user_email']=$user_email;

echo "<script>alert('You logged in successfully, Thanks!')</script>";
echo "<script>window.open('customer/my_account.php','_self')</script>";

}
else {
$_SESSION['user_email']=$user_email;

echo "<script>alert('You logged in successfully, Thanks!')</script>";
echo "<script>window.open('checkout.php','_self')</script>";
}
}
?>

最佳答案

您正在使用已弃用的方法。不鼓励使用 mySql_ 方法,而是使用 mysqli_ 方法。 (注意i)

替换

$run_c = mysql($con, $sel_c);
$check_customer = mysql_result($run_c);

$run_cart = mysqli_query($con, $sel_c); 
$rows = array();
while ($row = mysqli_fetch_assoc($run_cart)) {
$rows[] = $row;
}
<小时/>

您稍后在脚本中使用了 mysqli

$run_cart = mysqli_query($con, $sel_cart); 
$check_cart = mysqli_num_rows($run_cart);

关于php - 错误: Deprecated: Function mysql() is deprecated,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40746638/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com