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

<?php
  // 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>
      while($fet_query=mysql_fetch_array($userquery))
      {
          $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 } ?>
      </div>
      <?php } ?>

Recommended Answers

All 4 Replies

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.

commented: Good one +11

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.

ty guys all sorted with your help :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.