我正在尝试将其从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
?>
您不能简单地将mysql_ *替换为mysqli_ *。它们具有不同的语法。例如,您应该修复如何执行查询。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
?>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句