Gregoyle Posted March 28, 2011 Share Posted March 28, 2011 Alright first off, I don't know if this is a PHP or SQL problem. Second, I am not very knowledgeable in this subject at all the only reason I'm trying to get this to work is cause my buddy's computer is broken so he can't do much of anything (Would let him use mine but he lives half way across the country from me). So jumping right to the point we purchased this website about a month back cause it was going downhill and we thought this would be a great base to start from. So the following PHP script IS NOT written by us. Since i cant paste the script without it being a wall of text I'll have to tell you the issue BEFORE i post it. When you create the trade for example: Your Oddish His Squirtle It shows that but when you make ANOTHER separate trade for example: Your Lugia His Ho-Oh <-------------That's how it SHOULD look but it goes like this instead: Your Oddish Lugia His Squirtle Ho-Oh Now when you make the trade it adds into the SQL "traded" 1 instead of 0 so i was wondering if from the list of available Pokemon for trade if i could just have any Pokemon that has "Traded" as 1 to be removed from the list BUT NOT FROM THE GAME! Lol i tried DELETE FROM `poke_owned` WHERE `traded`='1' And lets just say that it didn't turn out well.... Now i don't know how much information your going to need so if you need more than just the trade script tell me. <?php session_start(); require_once 'dbconf.php'; include("figg.php"); if(!isset($_SESSION['user'])){ ?> <script language="text/javascript"> alert('You are not logged in.'); </script><? header ("Location: login.php"); } else{ session_start(); $snorretje1 = mysql_query("SELECT * FROM `users` WHERE `username`='" . $_SESSION['user'] . "'"); $snorretje = mysql_fetch_object($snorretje1); $user1 = mysql_query("SELECT * FROM `users` WHERE `id`='$snorretje->id'"); $user = mysql_fetch_object($user1); require_once 'figg.php'; $pokemon1 = mysql_query("SELECT * FROM `poke_owned` WHERE `trainer`='$user->username' AND `party1`='1'"); $pokemon = mysql_fetch_object($pokemon1); $poke1 = mysql_query("SELECT * FROM `pokemon` WHERE `name`='$pokemon->name'"); $poke = mysql_fetch_object($poke1); $amo1= mysql_query("SELECT * FROM `poke_owned` WHERE `trainer`='$user->username'"); $amo=mysql_num_rows($amo1); $trading1=mysql_query("SELECT * FROM `users` WHERE `id`='" . $_GET['q'] . "'"); $trading=mysql_fetch_object($trading1); $traderss1=mysql_query("SELECT * FROM `poke_owned` WHERE `box`='1' AND `trainer`='" . $trading->username . "' ORDER BY `name` ASC"); $traderss=mysql_fetch_object($traderss1); $owntraderss1=mysql_query("SELECT * FROM `poke_owned` WHERE `box`='1' AND `trainer`='" . $user->username . "' ORDER BY `name` ASC"); $owntraderss=mysql_fetch_object($owntraderss1); $nummer=mysql_num_rows($traderss1); ?> <?include("leftmenu.php");?> <?if($_GET['q']==""){?> <div class="title">Trade pokemon</div> <div class="contentcontent"> <br> <center> <?if(!isset($_POST['mytrade'])){ if(!isset($_POST['othertrade'])){?> Please enter the number of the trainer you would like to trade with:<br> <br> <form name="form" action="trade5.php" method="get"> <input type="text" name="q" /> <input type="submit" name="Submit" value="Trade" class="button" /> </form> <?}}}?> <?if($_GET['q']!=""){ if ($user->id == $_GET['q']) { echo "<div class=\"contentcontent\"><p class=\"title\">Trade pokemon</p><br><center>You can't trade yourself... Silly buns...</center></div>"; include("rightmenu.php"); exit; } $trading1=mysql_query("SELECT * FROM `users` WHERE `id`='" . $_GET['q'] . "'"); $trading=mysql_fetch_object($trading1); $trading1=mysql_query("SELECT * FROM `users` WHERE `id`='" . $_GET['q'] . "'"); $num=mysql_num_rows($trading1); if($num==0){echo("<center><b>No user found with that ID.</b></center>");} if($num==1){ ?> <div class="contentcontent"><p class="title">Trade pokemon with trainer #<?=$_GET['q']?></p> <form action="/trade5.php?a=<?=$_GET['q']?>" method="POST"><table class="w100"><tr><td class="w50"><p class="center">Your Pokémon<br /><select name="mytrade[]" multiple="multiple" size="20"><option value="niks" selected>(No Pokémon)</option><?while($owntradert=mysql_fetch_object($owntraderss1)){?><option value="<?=$owntradert->id?>"><?=$owntradert->name?> <?=$owntradert->gender?> (Level:<?=$owntradert->level?>)</option><?}?></select></p></td> <td class="w50"><p class="center"><?=$trading->username?>'s Pokémon<br /><select name="othertrade[]" multiple="multiple" size="20"><option value="niks" selected>(No Pokémon)</option><?while($tradert=mysql_fetch_object($traderss1)){?><option value="<?=$tradert->id?>"><?=$tradert->name?> <?=$tradert->gender?> (Level:<?=$tradert->level?>)</option><?}?></select></p></td></table> <center><input type="submit" value="Trade"> <?}} $bs=2; if ($bs == 1) { ?> ' <? } if(isset($_POST[mytrade])){ { $trading1=mysql_query("SELECT * FROM `users` WHERE `id`='" . $_GET['a'] . "'"); $trading=mysql_fetch_object($trading1); $id1=mysql_query("SELECT * FROM `trade`"); $id=mysql_fetch_object($id1); $numbl=mysql_num_rows($id1); if($numbl==0) { $tradeid=0; } else { $tradeid=$id->tradeid+1; } $ytrade=$_POST[mytrade]; if($ytrade){ foreach ($ytrade as $y) mysql_query("INSERT INTO `trade` (`from`, `to`, `pokid`,`tradeid`,`owner`) values('" . $user->id . "','" . $_GET['a'] . "','" . $y . "','" . $tradeid . "','" . $user->id . "')")or die(mysql_error()); $theother1=mysql_query("SELECT * FROM `users` WHERE `id`='" . $_GET['a'] . "'"); $theother=mysql_fetch_object($theother1); $error1=mysql_query("SELECT * FROM `poke_owned` WHERE `trainer`='" . $theother->username . "' AND `id`='" . $y . "' OR `trainer`='" . $user->username . "' AND `id`='" . $y . "'"); $error=mysql_num_rows($error1); if($error==0 && $y!=niks) { echo("Don't try to cheat!"); exit; } } if($ytrade){ foreach ($ytrade as $y) mysql_query("UPDATE poke_owned SET traded=1 WHERE id='" . $y . "'"); mysql_query("DELETE FROM `trade` WHERE `pokid`='niks'"); } { } } $otrade=$_POST[othertrade]; if($otrade){ foreach ($otrade as $o) mysql_query("INSERT INTO `trade` (`from`, `to`, `pokid`,`tradeid`, `owner`) values('" . $user->id . "','" . $_GET['a'] . "','" . $o . "','" . $tradeid . "','" . $_GET['a'] . "')")or die(mysql_error()); $theother1=mysql_query("SELECT * FROM `users` WHERE `id`='" . $_GET['a'] . "'"); $theother=mysql_fetch_object($theother1); $error1=mysql_query("SELECT * FROM `poke_owned` WHERE `trainer`='" . $theother->username . "' AND `id`='" . $o . "' OR `trainer`='" . $user->username . "' AND `id`='" . $y . "'"); $error=mysql_num_rows($error1); if($error==0 && $o!=niks) { echo("Don't try to cheat!"); exit; } } if($otrade){ foreach ($otrade as $o) mysql_query("UPDATE poke_owned SET traded=1 WHERE id='" . $o . "'"); mysql_query("DELETE FROM `trade` WHERE `pokid`='niks'"); } unset($_POST[mytrade]); unset($_POST[othertrade]); ?><meta http-equiv="Refresh" content="0; url=/traded.php"><? } ?> <br> <p> </p> <p class="center"> </p> </div> <?include("rightmenu.php");?> </html> <?}?> Link to comment https://forums.phpfreaks.com/topic/231959-cant-get-trade-script-for-my-pokemon-rpg-working/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.