Jump to content


Photo

trouble receiving an array


  • Please log in to reply
2 replies to this topic

#1 desithugg

desithugg
  • Members
  • PipPipPip
  • Advanced Member
  • 281 posts
  • LocationScarborough

Posted 21 August 2006 - 03:27 AM

im having trouble receiving a row (stored array) from a mysql database.
what is stored in the row is
"1134, 960" im using the fallowing query
$tid = $_GET['id'];
 $link = mysql_connect('localhost', $my_sql_password, $my_sql_username);
if (!$link) {
   die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db('osiris_thugg');
if (!$db_selected) {
   die('Could not select database: ' . mysql_error());
}
$query = "SELECT creator,id,completer,sitems,eitems FROM trade where id = '$tid'"; 
	 $result = mysql_query($query) or die(mysql_error());
     while($row = mysql_fetch_array($result)){
     $spokes = $row['sitems'];
     $epokes = $row['eitems'];
echo "<tr><td class='ftable2'>". $row['creator'] ."'s items". $row['eitems'] ."</td><td class='ftable2'>". $row['completer'] ."'s items</td></tr>";
}
?>
this echos the fallowing

darkness's items1134, 960

than i use
<?
$sitems2 = explode(", ", $sitems);
$eitems2 = explode(", ", $eitems);
 $link = mysql_connect('localhost', $my_sql_password, $my_sql_username);
if (!$link) {
   die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db('osiris_thugg');
if (!$db_selected) {
   die('Could not select database: ' . mysql_error());
}
$query = "SELECT name,level,gender FROM character where item_id IN ($sitems2)"; 
	 $result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
$gender = $row['gender'];
if($gender == "Male")
{
$g2 = "M";
}
if($gender == "Female")
{
$g2 = "F";
}
if($gender == "Ungenderd")
{
$g2 = "U";
}
if($gender == "Transexual")
{
$g2 = "T";
}
if($gender == "Genderless")
{
$g2 = "G";
}
echo"-". $row['name'] ."LV.". $row['level'] ."($g2)";
}
?>
but this keeps giving me the fallworing error
Unknown column 'Array' in 'where clause'
it should work since there i used explode to make it into an array
i tried using implode but it gives me some other error something like bad_argument(); where implde.....


#2 desithugg

desithugg
  • Members
  • PipPipPip
  • Advanced Member
  • 281 posts
  • LocationScarborough

Posted 21 August 2006 - 04:55 AM

bump
any1
well just gonna bump the thread and go to sleep and check on it in the morning any1 help...

#3 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 21 August 2006 - 05:16 AM

Unknown column 'Array' in 'where clause'

it should work since there i used explode to make it into an array.


That's exactly why it doesn't work.  IN does not want an array, it wants a comma separated list - which is exactly what $sitem2 was before you exploded it into an array. Try it without exploding ...
Legend has it that reading the manual never killed anyone.
My site




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users