Hi im getting this error on inobox.php any ideas please

Warning: implode(): Invalid arguments passed in /home/jktempla/public_html/SCRIPTS/DATINGSCRIPT/inbox.php on line 199

  // Fetch user random for display on bottom
<THIS LINE>$idtopuid     = implode(',', $topuid);<THIS LINE>
    <THIS> $userquery    = mysql_query("select * from user where user_id != '".$_SESSION['userid']."' and user_id NOT IN (".$idtopuid.") order by rand() limit 0,5");<LINE>
          $show_gender  = $fet_query['user_gender'];
          $show_id      = $fet_query['user_id']; 
          $fetch_img2   = mysql_fetch_array(mysql_query("select user_image from user_images where user_id = '".$show_id."' and main_image = '1' "));
          $show_img     = $fetch_img2['user_image'];
      <div class="box">
        <?php if($show_img != '') { ?>
        <a href="viewprofile.php?profid=<?php echo $show_id;?>&gen=<?php echo $show_gender;?>"><img src="images/user_images/smallthumb/<?php echo $show_img;?>" border="0" width="100" height="80"/></a>
        <?php } else { ?>
        <a href="viewprofile.php?profid=<?php echo $show_id;?>&gen=<?php echo $show_gender;?>"><img src="images/blank.jpg" border="0" width="100" height="80" /></a>
        <?php } ?>
      <?php } ?>
3 Years
Discussion Span
Last Post by janicemurby

It seems that the $topuid variable is not an array (the implde function expects an array). Can you check it out? You can put this code just before line 3 in the above code:

die(print_r($topuid, 1));

This will display the value of the variable and stop the script. Please post the value here.


Agreed with @broj1 where your $topuid is probably not defined as an array. And the cause is actually can be found easily by paste the error to google. Here is what I do: echo implode(', ', (array)$topuid);, with this code, the $topuid will be cast into an array for implode.

Votes + Comments
Good one

Here is what I do: echo implode(', ', (array)$topuid);, with this code, the $topuid will be cast into an array for implode.

Casting is a good idea. You also have to cater for the query to work when the $topuid is empty.

$inCondition = $topuid != "" ?  " and user_id NOT IN ($idtopuid)" : "";
$userquery = mysql_query("select * from user where user_id != '{$_SESSION['userid']}'" . $inCondition . " order by rand() limit 0,5");

Note that I embeded variables directly into the doublequoted string.

Edited by broj1

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.