gpt4 book ai didi

php 函数不更新 mysql 数据库

转载 作者:行者123 更新时间:2023-11-29 14:52:01 26 4
gpt4 key购买 nike

我有一个问题,无法找到解决方法。我有以下内容:

db("select * from {$game}_stars where event_random = '11'");

$sn_sys = dbr();
if($sn_sys['event_random'] == 11)

dbn("update {$game}_stars set event_random = 6 where event_random = '11, metal = '583720', fuel='948372', star_name = 'SuperNova Remnant' where star_id = '$sn_sys[star_id]'");
dbn("insert into {$game}_news (timestamp, headline, login_id) values (".time().",'The star in <b class=b1>system $sn_sys[star_id]</b> has exploded destroying everything in the system, and leaving a <b class=b1>Supernova Remnant</b> which is extremly rich in metals and fuel. All adjoining systems have also recieved generous quantities of minerals. We believe the SuperNova Remnant will turn into a <b>Blackhole</b> over due course.<font color=lime>- - - Science Institute of Sol - - -</font>','-11')");

#take out non-eps.
db2("select * from {$game}_ships where location = '$sn_sys[star_id]' && login_id !='1'");
while ($ship_sn = dbr()) {
if ($ship_sn['shipclass'] != 2) {
dbn("insert into {$game}_messages (timestamp,sender_name,sender_id, login_id, text) values(".time().",'SuperNova','$ship_sn[login_id]','$ship_sn[login_id]','Your ship the <b class=b1>$ship_sn[ship_name]</b> was destroyed by an exploding star (<b>Supernova</b>) in system #<b>$ship_sn[location]</b>')");
dbn("delete from {$game}_ships where ship_id = '$ship_sn[ship_id]'");
dbn("insert into {$game}_news (timestamp, headline, login_id) values (".time().",'$ship_sn[login_name] lost a $ship_sn[class_name] to the SuperNova in system #<b>$ship_sn[location]<b>','$ship_sn[login_id]')");
} else {
dbn("insert into {$game}_messages (timestamp,sender_name,sender_id, login_id, text) values(".time().",'SuperNova','$ship_sn[login_id]','$ship_sn[login_id]','Your <b>Escape Pod</b> was near a star when it exploded. Fortunatly is was not hurt by the explosion, but was flung to a different system. Some well-wisher then brought you to system #1.')");
dbn("update {$game}_users set location = '1' where ship_id = '$ship_sn[ship_id]'");
dbn("update {$game}_ships set location = '1' where login_id = '$ship_sn[login_id]'");
}
}

#take out non admin planets
db2("select * from {$game}_planets where location = '$sn_sys[star_id]' && owner_id != '1'");

while ($planet_sn = dbr2()) {
dbn("insert into {$game}_messages (timestamp,sender_name,sender_id, login_id, text) values(".time().",'SuperNova','$planet_sn[owner_id]','$planet_sn[owner_id]','Your planet (<b class=b1>$planet_sn[planet_name]</b>) was oblterated by an exploding star (<b>Supernova</b>) in system #<b>$planet_sn[location]. It no longer excists, nor does anything that was on it.')");
dbn("delete from {$game}_planets where planet_id = $planet_sn[planet_id]");
dbn("insert into {$game}_news (timestamp, headline, login_id) values (".time().",'The planet $planet_sn[planet_name] was totally destroyed by the SuperNova in system #<b>$planet_sn[location]<b>','$planet_sn[owner_id]')");
}

#move users to sol or next ship
db2("select * from {$game}_users where location = '$sn_sys[star_id]' && login_id > '3' && ship_id != 1");

while($users = dbr2()) {
db("select * from {$game}_ships where login_id = '$users[login_id]' && login_id != 1");

if($other = dbr()) {
dbn("update {$game}_users set ship_id = '$other[ship_id]', location = '$other[location]' where login_id = '$other[login_id]'");
dbn("insert into {$game}_messages (timestamp,sender_name,sender_id, login_id, text) values(".time().",'SuperNova','$users[login_id]','$users[login_id]','Command was transfered to the <b class=b1>$other[ship_name]</b>.')");
} else {
dbn("insert into {$game}_messages (timestamp,sender_name,sender_id, login_id, text) values(".time().",'SuperNova','$users[login_id]','$users[login_id]','You ejected in an escape pod.')");
dbn("insert into {$game}_ships (ship_name, login_id, login_name, shipclass, class_name, location, point_value) values('Escape Pod','$users[login_id]','$users[login_name]',2,'Escape Pod','1',5)");

dbn("select * from {$game}_ships where login_id = '$users[login_id]'");

$ship_id = dbr();
dbn("update {$game}_users set location = '1', ship_id ='$ship_id[ship_id]' where login_id = '$users[login_id]'");
}
}


db("select * from {$game}_stars where star_id = '$sn_sys[star_id]'");

$link = dbr();
$link_1 = $link['link_1'];
$link_2 = $link['link_2'];
$link_3 = $link['link_3'];
$link_4 = $link['link_4'];
$link_5 = $link['link_5'];
$link_6 = $link['link_6'];

dbn("update {$game}_stars set fuel= fuel +'103482', metal= metal+'12354' where star_id != '1' && star_id != 0 && star_id = '$link_1'");
dbn("update {$game}_stars set fuel= fuel +'95444', metal= metal+'56484' where star_id != '1' && star_id != 0 && star_id = '$link_2'");
dbn("update {$game}_stars set fuel= fuel +'74452', metal= metal+'46877' where star_id != '1' && star_id != 0 && star_id = '$link_3'");
dbn("update {$game}_stars set fuel= fuel +'37353', metal= metal+'106210' where star_id != '1' && star_id != 0 && star_id = '$link_4'");
dbn("update {$game}_stars set fuel= fuel +'74523', metal= metal+'68757' where star_id != '1' && star_id != 0 && star_id = '$link_5'");
dbn("update {$game}_stars set fuel= fuel +'63452', metal= metal+'83254' where star_id != '1' && star_id != 0 && star_id = '$link_6'");

print "<br />Supernova in $sn_sys[star_id] went bang.<br />";
}

设置此脚本后,它会在数据库中插入一条包含事件规范的消息,当然还要运行查询。

现在,只有

insert into {$game}_news

似乎已得到处理,而其他所有内容均未处理。

这是我的数据库函数

function db($string) {
global $query;
$query = mysql_query($string);
}

function dbr()
{
global $query;
$fetched = $query->fields;
return $fetched;
}
function db2($string) {
global $query2;
$query2 = mysql_query($string);
}

function dbr2()
{
global $query2;
$fetched2 = $query2->fields;
return $fetched2;
}

函数dbn

function dbn($string) {
mysql_query($string);
}

关于原因和任何可能的解决方案有什么想法吗?感谢您的阅读。

最佳答案

您能否尝试将 '$ship_sn[ship_id]' 更改为 '{$ship_sn[ship_id]}'

关于php 函数不更新 mysql 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5536465/

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