errors in inbox before amd after swapping to mysqli

hya im moving my site to mysqli and i have a error in inbox file can anyone advice how to solve this the error is below:
Warning: implode(): Invalid arguments passed in /home/jktempla/public_html/Softdatepro/completed/inbox.php on line 199

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/jktempla/public_html/Softdatepro/completed/inbox.php on line 201

and the code for that section is
[php]// Fetch user random for display on bottom
$idtopuid = implode(’,’, $topuid);
$userquery = mysqli_query($conn,“select * from user where user_id != '”.$_SESSION[‘userid’]."’ and user_id NOT IN (".$idtopuid.") order by rand() limit 0,5");
while($fet_query=mysqli_fetch_array($userquery))
{
$show_gender = $fet_query[‘user_gender’];
$show_id = $fet_query[‘user_id’];
$fetch_img2 = mysqli_fetch_array(mysqli_query($conn,“select user_image from user_images where user_id = '”.$show_id."’ and main_image = ‘1’ "));
$show_img = $fetch_img2[‘user_image’];
?>


<?php if($show_img != '') { ?>

<?php } else { ?>

<?php } ?>

<?php } ?>[/php]

the underlined and bold are the lines indicated in the error message

and help would be much appreciated ty jan

Other than being hard to read and wasted code in your <a hef’s, how have you debugged this so far? I would
just kill the code before the display

and display the values to see if you are catching them before they
are displayed. In this way, you will know what is being displayed. To debug that, you can display them like
this:
[php]
echo “show_image=” . $show_image . “
show_id=” . $show_id . “
show_gender=” . $show_gender . “
”;
die(“are these correct?”);
?>

[/php]
This will kill the page and let you see the two values. If they are correct something is wrong in your div code
where it shows the links. If they are not correct, recheck your query.

To make all this easier to read, you can just alter the code after the query like this:

Instead of:
[php]
?>


<?php if($show_img != '') { ?>

<?php } else { ?>

<?php } ?>

<?php } ?>
[/php]
Try this:
[php]
echo ‘
’;
if ($show_img != ‘’) {
echo ‘’;
} else {
echo ‘’;
}
echo ‘
’;
}
?>
[/php]
(Easier to read to me at least!)

[member=43746]ErnieAlex[/member] , still twice as much code than needed. The only difference is the image SRC. Why duplicate all that code?

And please don’t echo html, for one it messes up your IDEs syntax highlighting. The only improvement I’d do (in that regard) is to change to shorthand echoes
[php] ?>


<?php if($show_img != '') { ?>

<?php } else { ?>

<?php } ?>

<?php } ?>[/php]

Then you of course could change it to only make the img src conditional

[php]// You didn’t have the leading slashes, but I guess they should be there
$src = $show_img != ‘/images/user_images/smallthumb/’ . $show_img : ‘/images/blank.jpg’;
$url = ‘viewprofile.php?profid=’ . $show_id . ‘&gen=’ . $show_gender;

?>






<?php } // you had a wild trailing slash, guessing it belongs outside the snippet you pasted.[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service