gpt4 book ai didi

php - 我在这里遇到错误,所以帮助我

转载 作者:行者123 更新时间:2023-11-29 10:07:51 25 4
gpt4 key购买 nike

<?php
$conn=mysqli_connect("localhost","root","","telephasic");
if(isset($_GET['role']))
{
$role1=$_GET['role'];
$query = "SELECT * FROM register WHERE id='$role1'";
while($row=mysql_fetch_object($query))
{
$role_var=$row->role;
if($role_var=='1')
{
$role_state="NULL";
} else {
$role_state="0";
}
$update=mysql_query("update register set status='$role_state' where id='$role1' ");
if($update)
{
header("Location:admin.php");
} else {
echo mysql_error();
}
}
?>
<?php } ?>

我在这里遇到错误,请帮助我

Fatal error: Uncaught Error: Call to undefined function mysql_fetch_object() in C:\xampp\htdocs\telephasic\action.php:7 Stack trace: #0 {main} thrown in C:\xampp\htdocs\telephasic\action.php on line 7

最佳答案

尝试使用以下代码:

   <?php
$conn=mysqli_connect("localhost","root","","telephasic");
if(isset($_GET['role']))
{
$role1=$_GET['role'];
$query = "SELECT * FROM register WHERE id='$role1'";
$result=mysqli_query($conn,$query); // u need to execute query first!!
while($row=mysqli_fetch_object($result))
{
$role_var=$row->role;
if($role_var=='1')
{
$role_state="NULL";
} else {
$role_state="0";
}
$update=mysqli_query($conn, "update register set status='$role_state' where id='$role1' ");
if($update)
{
header("Location:admin.php");
} else {
echo mysqli_error();
}
}
?>
<?php } ?>

关于php - 我在这里遇到错误,所以帮助我,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51552695/

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