Jump to content

trouble receiving an array


desithugg

Recommended Posts

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
[code]
$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>";
}
?>
[/code]
this echos the fallowing
[quote]
darkness's items1134, 960
[/quote]
than i use
[code]
<?
$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)";
}
?>
[/code]
but this keeps giving me the fallworing error
[code]Unknown column 'Array' in 'where clause'[/code]
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.....
Link to comment
Share on other sites

[quote][code]Unknown column 'Array' in 'where clause'[/code]

it should work since there i used explode to make it into an array.[/quote]

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 ...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.