从mysql到mysqli的更新与从数据库中提取数据有关

hujrc8aj  于 2021-06-25  发布在  Mysql
关注(0)|答案(1)|浏览(324)

我想把这个从mysql更新到mysqli,但是我在这样做的时候经常遇到错误。基本上,这是从另一个页面上的链接创建的动态页面的一段代码。

$connect = mysql_connect('localhost', 'root', 'Password');
$select_db = mysql_select_db('playerslog');

$id = mysql_real_escape_string($_GET['UUID']);
//Remove LIMIT 1 to show/do this to all results.
$query = 'SELECT * FROM `playerslog` WHERE `UUID` = '.$id.' LIMIT 1';
$result = mysql_query($query);
$row = mysql_fetch_array($result);
// Echo page content

有什么建议可以帮我完成吗?谢谢你的时间!
按要求更新。

<?php
$connect = mysqli_connect('localhost', 'root', 'Password');
$select_db = mysqli_select_db('playerslog');

$id = mysqli_real_escape_string($_GET['UUID']);
//Remove LIMIT 1 to show/do this to all results.
$query = 'SELECT * FROM `playerslog` WHERE `UUID` = '.$id.' LIMIT 1';
$result = mysqli_query($query);
$row = mysqli_fetch_array($result);
// Echo page content

?>
atmip9wb

atmip9wb1#

你不能简单地用mysqli替换mysql。它们有不同的语法。例如,您应该确定如何执行查询。mysqli需要两个参数:连接和查询。您只需传递查询:

<?php
$connect = mysqli_connect('localhost', 'root', 'Password');
$select_db = mysqli_select_db('stats');
$id = mysqli_real_escape_string($_GET['UUID']);
//Remove LIMIT 1 to show/do this to all results.
$query = 'SELECT * FROM `playerslog` WHERE `UUID` = '.$id.' LIMIT 1';
$result = mysqli_query($connect, $query);
$row = mysqli_fetch_array($result);
// Echo page content

?>

相关问题