gpt4 book ai didi

php - 转换 mqsql_query 弃用

转载 作者:行者123 更新时间:2023-11-29 04:38:43 25 4
gpt4 key购买 nike

我开始意识到 mysql_query 已被弃用。我需要做什么来解决这个问题?因为所有这些都是 MySQL。

一个简单的事实是,我需要重新编码我的整个网站,以免它因已弃用的功能而无法正常工作。

if (!$_GET['XID']) {
$mystats = array();
$s = array();
$mystats = mysql_query ("SELECT * FROM `members_personal` WHERE playerid = '{$_SESSION['playerid']}'");
$s = mysql_fetch_array($mystats);
echo '<center><main>Personal stats</main>
<hr width="93%">
<table width = "75%" class = "rounded"><tr><td width=45% valign=top>
' . round_table('700') . '<table class = "vnm-table" width=100% cellspacing=1 cellpadding=3>
<tr bgcolor=#999999><th align="left" width=70%>
<b>Attacking</b>
</th><th width=30%></th></tr>
<tr bgcolor=#DFDFDF>
<td>Attacks won:</td>
<td>' . number_format($s['my_attwon']) . '</td>
</tr><tr bgcolor=#CCCCCC>
<td>Attacks lost:</td>
<td>' . number_format($s['my_attlost']) . '</td>
</tr><tr bgcolor=#DFDFDF>
<td>Attacks stalemated:</td>
<td>' . number_format($s['my_attstale']) . '</td>
</tr><tr bgcolor=#CCCCCC>
<td>Defends won:</td>
<td>' . number_format($s['my_defwon']) . '</td>
</tr><tr bgcolor=#DFDFDF>
<td>Defends lost:</td>
<td>' . number_format($s['my_deflost']) . '</td>
</tr><tr bgcolor=#CCCCCC>
<td>Defends stalemated:</td>
<td>' . number_format($s['my_defstale']) . '</td>
</tr><tr bgcolor=#DFDFDF>
<td>Win/Loss ratio:</td>
<td>';

$attwon = array();
$attlost = array();
$first_number = array();
$second_number = array();
$div_value = array();
$attwon = $s['my_attwon'] + $s['my_defwon'];
$attlost = $s['my_attlost'] + $s['my_deflost'];

$div_value = "0.0";
if ($attlost == 0) {
$attlost = '1';
}
$div_value = $attwon / $attlost;

printf("%01.2f", $div_value);

echo '</td>
</tr><tr bgcolor=#CCCCCC>
<td>Times ran away:</td>
<td>' . number_format($s['my_timesran']) . '</td>
</tr><tr bgcolor=#DFDFDF>
<td>Foes ran away:</td>
<td>' . number_format($s['my_theyran']) . '</td>
</tr><tr bgcolor=#CCCCCC>
<td>Best kill streak:</td>
<td>' . number_format($s['my_beststreak']) . '</td>
</tr><tr bgcolor=#DFDFDF>
<td>Current kill streak:</td>
<td>' . number_format($s['my_currstreak']) . '</td>
</tr><tr bgcolor=#CCCCCC>
<td>Hits:</td>
<td>' . number_format($s['my_hits']) . '</td>
</tr><tr bgcolor=#DFDFDF>
<td>Misses:</td>
<td>' . number_format($s['my_misses']) . '</td>
</tr><tr bgcolor=#CCCCCC>
<td>Total damage made:</td>
<td>' . number_format($s['my_totaldamage']) . '</td>
</tr><tr bgcolor=#DFDFDF>
<td>Best damage made:</td>
<td>' . number_format($s['my_bestdamage']) . '</td>
</tr><tr bgcolor=#CCCCCC>
<td>One hit kills:</td>
<td>' . number_format($s['my_onehitkill']) . '</td>
</tr><tr bgcolor=#DFDFDF>
<td>Critical hits:</td>
<td>' . number_format($s['my_crithits']) . '</td>
</tr><tr bgcolor=#CCCCCC>
<td>Rounds fired:</td>
<td>' . number_format($s['my_rounds']) . '</td>
</tr><tr bgcolor=#DFDFDF>
<td>Stealth attacks:</td>
<td>' . number_format($s['my_stealths']) . '</td>
</tr><tr bgcolor=#CCCCCC>
<td>Money mugged:</font></td>
<td>$' . number_format($s['my_muggain']) . '</td>
</tr><tr bgcolor=#DFDFDF>
<td>Highest level beaten:</td>
<td>' . number_format($s['my_bestlevel']) . '</td>
</tr><tr bgcolor=#CCCCCC>
<td>Total respect gained:</td>
<td>' . number_format($s['my_respectgain']) . '</td>
</tr>
</table>

最佳答案

正如 user3284463 所建议的那样,mysqli_*函数是更新旧代码而无需完全重写的简单方法。它们通常会替换它们的 mysql_* 对应项。

也就是说,如果您有时间,我会听取 rehmat 的建议并学习 PDO。

关于php - 转换 mqsql_query 弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34690622/

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