Danyal Posted February 4, 2007 Share Posted February 4, 2007 I have a trade script; There is two parts to this script: CreateTrade.php: <? if(isset($_SESSION['user'])) { $other = $_GET['with']; $query = mysql_query("SELECT * FROM trainers where Username = '$other' limit 1") or die(mysql_error()); $row = mysql_fetch_array( $query ); $other_id = $row["Username"]; $other_name = $row["Username"]; if($other_id == "") { print "The Username You Are Trying To Trade with Does Not Exist!"; } else { $query = mysql_query("SELECT count(*) as ID FROM t_pokemon where Trainer = '$getuser3[username]'") or die(mysql_error()); $row = mysql_fetch_array( $query ); $my_count = $row["ID"]; if($my_count <= "7") { $other_id = ""; print "You Do Not Have Enough Pokemon To Participate In A Trade!"; } else { $query = mysql_query("SELECT count(*) as ID FROM t_pokemon where Trainer = '$other_name'") or die(mysql_error()); $row = mysql_fetch_array( $query ); $other_count = $row["ID"]; if($other_count <= "7") { $other_id = ""; print "The User You Are Trying To Trade with Does Not Have Any Pokemon In Their Box!"; } else { if($other_id != "") { echo" Welcome To The TPPA's Trading Center! Please Note That All Of The Trades Are Monitored, And Anyone Caught Cheating Will Be Banned! This Is Your First And Last Warning!<br /><b>Hold Down The CTRL/SHIFT Key To Select More Than One Pokemon.</b> <table class='top' align='center' width='100%'> <tr><td class='top'>$getuser3[username]'s Pokemon</td><td class='top'>$other_name's Pokemon</td> <form action='index.php?function=FCreateTrade' method='POST'> <input type='hidden' name='other' value='$other_id'> <tr><td class='top'><select name='my_pokemon[]' multiple='multiple' size='20'> "; } if($other_id != ""){ $query = "SELECT * FROM t_pokemon where Trainer = '$getuser3[username]'"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ $Gender = $row['Gender']; $pid = $row['ID']; $pokemon = $row['Pokemon']; $level = $row['Level']; if($Gender == "Male") { $g2 = "M"; } if($Gender == "Female") { $g2 = "F"; } echo"<option value='$pid'>".$pokemon."Lv.$level($g2)</option>"; } echo"</select></td>"; } if($other_id != ""){ echo"<td class='top'><select name='other_pokemon[]' multiple='multiple' size='20'>"; } if($other_id != ""){ $query = "SELECT * FROM t_pokemon where Trainer = '$other_name'"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ $gender = $row['Gender']; $pid = $row['ID']; $pokemon = $row['Pokemon']; $level = $row['Level']; if($Gender == "Male") { $g2 = "M"; } if($Gender == "Female") { $g2 = "F"; } echo"<option value='$pid'>".$pokemon."Lv.$level($g2)</option>"; } echo"</select></td></tr><tr> <td class='top'> <input type='submit' value='Create' class='SearchB'> </td><td class='top'><input type='button' value='cancel' class='SearchB'></td></tr> </form> </table>"; } } } } } if(!isset($_SESSION['user'])) { print "<font face='verdana' size='1'>You Must Be Logged In To Create A Trade!"; } ?> FTrade.php: <?php include('connect.php'); if(isset($_SESSION['user'])) { $my_pokemon = $_POST['my_pokemon']; $other_id = $_POST['other']; $other_pokemon = $_POST['other_pokemon']; if($my_pokemon == "") { print "Sorry You Did Not Select A Pokemon From Your List!"; } else { if($other_pokemon == "") { print "Sorry you did not selcet a pokemon from the completer's list."; } else { $m2 = implode(', ', $my_pokemon); $o2 = implode(', ', $other_pokemon); $query = "SELECT count(ID) FROM t_pokemon where Trainer = '$getuser3[username]' && ID IN ($m2)"; $result = mysql_query($query) or die(mysql_error()); $my_check1 = mysql_result($result, 0); $query = "SELECT count(ID) FROM t_pokemon where Trainer = '$other_id' AND ID IN ($o2)"; $result = mysql_query($query) or die(mysql_error()); $other_check1 = mysql_result($result, 0); if($my_check1 != count($my_pokemon)) { print "One or more of the pokemon selected never did or does not belong to you."; } else { if($other_check1 != count($other_pokemon)) { $error = "<center>One or more of the pokemon selected never did or no longer belongs to the completer.<br>Or the pokemon(s) are not in the completers box."; header("Location: ds.php?action=form&show_mes=$error"); exit; } else { $query = "SELECT sum(Level) FROM t_pokemon where ID IN ($o2)"; $result = mysql_query($query) or die(mysql_error()); $slevel = mysql_result($result, 0); $query = "SELECT sum(Level) FROM t_pokemon where ID IN ($m2)"; $result = mysql_query($query) or die(mysql_error()); $mlevel = mysql_result($result, 0); mysql_query("INSERT INTO Trades (Creator, Completer, SPokes, EPokes, SLevel, NLevel) VALUES ('$getuser3[userID]','$Other_ID','$m2','$o2','$slevel','$mlevel')") or die(mysql_error()); $query = "SELECT ID FROM Trade where Creator = '$getuser3[iD]' && Completer = '$Other_ID' order by ID desc limit 1"; $result = mysql_query($query) or die(mysql_error()); $tid = mysql_result($result, 0); print "Trade Is Made Succefully! The Trade ID Is <b>$tid</b>. Give This Trade ID To The Completer!"; } } } } } if(!isset($_SESSION['user'])) {print "<font face='verdana' size='1'><center>You Must Be Logged In To Create A Trade!";} ?> My problem is this: Warning: implode() [function.implode]: Bad arguments. in /home/.keerokee/tpparpg/tpparpg.com/Version3/FCreateTrade.php on line 22 Warning: implode() [function.implode]: Bad arguments. in /home/.keerokee/tpparpg/tpparpg.com/Version3/FCreateTrade.php on line 23 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 Can anybody help me? Thank you, Danyal Link to comment https://forums.phpfreaks.com/topic/36971-help/ Share on other sites More sharing options...
Balmung-San Posted February 4, 2007 Share Posted February 4, 2007 Implode turns an array into a string. I think you want explode. Link to comment https://forums.phpfreaks.com/topic/36971-help/#findComment-176453 Share on other sites More sharing options...
Danyal Posted February 4, 2007 Author Share Posted February 4, 2007 So I would do: $m2 = explode(', ', $my_pokemon); $o2 = explode(', ', $other_pokemon); ? Thanks, Danyal Link to comment https://forums.phpfreaks.com/topic/36971-help/#findComment-176455 Share on other sites More sharing options...
Danyal Posted February 4, 2007 Author Share Posted February 4, 2007 Now I get: Unknown column 'Array' in 'where clause' Link to comment https://forums.phpfreaks.com/topic/36971-help/#findComment-176459 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.