Php+;mysql,时隙交换 好的,所以我正在制作一个基于Pokimon网络的RPG,并且它已经正常运行了,除了OW IM在我需要切换存储在插槽(0)中的Pokimon =你的盒子到你的团队的插槽1的那一部分。我已经弄明白了,所以它会将存储在0槽中的口袋妖怪切换到你团队的1槽,但它只适用于0槽列表中的第一个(有多个槽设置为0)。我希望我需要它,这样我就可以在你的框中的任何口袋妖怪下单击提交,它会将它发送到1槽 以下是我目前的代码: <?php include 'core/database/connect.php'; include 'core/init.php'; protect_page(); include 'includes/overall/header.php'; ?> <div id="middle"> <div class="post"> <div class="postheader"> <h1>Your Box</h1> </div> <div class="postcontent"> <p> <center> <?php if (isset($_POST['slot1'])) { session_start(); // here we grab the pokemon in slot 1 $sql66 = "SELECT * FROM user_pokemon WHERE belongsto='".$_SESSION['username']."' AND (slot='1')"; $result66 = mysql_query($sql66) or die(mysql_error()); $poke66 = mysql_fetch_array($result66); $sql55 = "SELECT * FROM user_pokemon WHERE belongsto='".$_SESSION['username']."' AND (slot='0')"; $result55 = mysql_query($sql55) or die(mysql_error()); $poke55 = mysql_fetch_array($result55); $_SESSION['idpoke5'] = $poke55['id'] ; $_SESSION['idpoke6'] = $poke66['id'] ; if(mysql_num_rows($result66)==0){ echo "no pokemon in slot 6 so we will drag the pokemon from slot 5 into slot 6 "; } else { $result666 = mysql_query("UPDATE user_pokemon SET slot=slot-1 WHERE id = '{$_SESSION['idpoke6']}'") or die(mysql_error()); header( 'Location: index.php' ) ; } if(mysql_num_rows($result55)==0){ echo "no pokemon in slot 5"; } else { $result5done = mysql_query("UPDATE user_pokemon SET slot=slot+1 WHERE id = '{$_SESSION['idpoke5']}'") or die(mysql_error()); } ?> <?php echo "Your pokemon has been moved"; } $result = mysql_query("SELECT * FROM user_pokemon WHERE belongsto='". $_SESSION{'username'}."'AND (slot='0')"); while($row = mysql_fetch_array($result)) { $sql2 = "SELECT * FROM pokemon WHERE name='".$row['pokemon']."'"; $result2 = mysql_query($sql2) or die(mysql_error()); $battle_get2 = mysql_fetch_array($result2); echo '<img src="pokemon/'.$row['type'] .''.$battle_get2['pic'].'" border=0><p></p> </a>' ; echo $row['pokemon']; ?> <p></p> <?php echo "Level:"; echo $row ['level']; ?> <p><form name="slot1" action="" method="post"> <div align="center"> <input type="submit" value="slot1" name="slot1"> </div> </form> </p> <?php echo "Gender:"; echo $row['gender']; echo "<br />"; } ?> </center> </p> </div> <div class="postfooter"></div> </div> 你的箱子

Php+;mysql,时隙交换 好的,所以我正在制作一个基于Pokimon网络的RPG,并且它已经正常运行了,除了OW IM在我需要切换存储在插槽(0)中的Pokimon =你的盒子到你的团队的插槽1的那一部分。我已经弄明白了,所以它会将存储在0槽中的口袋妖怪切换到你团队的1槽,但它只适用于0槽列表中的第一个(有多个槽设置为0)。我希望我需要它,这样我就可以在你的框中的任何口袋妖怪下单击提交,它会将它发送到1槽 以下是我目前的代码: <?php include 'core/database/connect.php'; include 'core/init.php'; protect_page(); include 'includes/overall/header.php'; ?> <div id="middle"> <div class="post"> <div class="postheader"> <h1>Your Box</h1> </div> <div class="postcontent"> <p> <center> <?php if (isset($_POST['slot1'])) { session_start(); // here we grab the pokemon in slot 1 $sql66 = "SELECT * FROM user_pokemon WHERE belongsto='".$_SESSION['username']."' AND (slot='1')"; $result66 = mysql_query($sql66) or die(mysql_error()); $poke66 = mysql_fetch_array($result66); $sql55 = "SELECT * FROM user_pokemon WHERE belongsto='".$_SESSION['username']."' AND (slot='0')"; $result55 = mysql_query($sql55) or die(mysql_error()); $poke55 = mysql_fetch_array($result55); $_SESSION['idpoke5'] = $poke55['id'] ; $_SESSION['idpoke6'] = $poke66['id'] ; if(mysql_num_rows($result66)==0){ echo "no pokemon in slot 6 so we will drag the pokemon from slot 5 into slot 6 "; } else { $result666 = mysql_query("UPDATE user_pokemon SET slot=slot-1 WHERE id = '{$_SESSION['idpoke6']}'") or die(mysql_error()); header( 'Location: index.php' ) ; } if(mysql_num_rows($result55)==0){ echo "no pokemon in slot 5"; } else { $result5done = mysql_query("UPDATE user_pokemon SET slot=slot+1 WHERE id = '{$_SESSION['idpoke5']}'") or die(mysql_error()); } ?> <?php echo "Your pokemon has been moved"; } $result = mysql_query("SELECT * FROM user_pokemon WHERE belongsto='". $_SESSION{'username'}."'AND (slot='0')"); while($row = mysql_fetch_array($result)) { $sql2 = "SELECT * FROM pokemon WHERE name='".$row['pokemon']."'"; $result2 = mysql_query($sql2) or die(mysql_error()); $battle_get2 = mysql_fetch_array($result2); echo '<img src="pokemon/'.$row['type'] .''.$battle_get2['pic'].'" border=0><p></p> </a>' ; echo $row['pokemon']; ?> <p></p> <?php echo "Level:"; echo $row ['level']; ?> <p><form name="slot1" action="" method="post"> <div align="center"> <input type="submit" value="slot1" name="slot1"> </div> </form> </p> <?php echo "Gender:"; echo $row['gender']; echo "<br />"; } ?> </center> </p> </div> <div class="postfooter"></div> </div> 你的箱子,php,mysql,Php,Mysql,我被告知要在php的第一行使用session\u start(),我不确定它是否会导致问题,但我认为您的问题有点严重,只要在发布任何内容或使用任何其他会话函数或$\u session本身之前使用它,它就可以正常工作。除非启用了输出缓冲,否则在发出内容后将其放在此处可能会中断。


我被告知要在php的第一行使用
session\u start()
,我不确定它是否会导致问题,但我认为您的问题有点严重,只要在发布任何内容或使用任何其他会话函数或
$\u session
本身之前使用它,它就可以正常工作。除非启用了输出缓冲,否则在发出内容后将其放在此处可能会中断。