<?php $post_query = mysql_query("SELECT * FROM `post` WHERE `user1`=$myrow2[id] OR `user2`='$id' ORDER BY `id` DESC"); while ($run_post = mysql_fetch_array($post_query)) { $post_id = $run_post['id']; $post = $run_post['post']; $post_date = $run_post['date']; $post_time = $run_post['time']; $username = getuser($myrow['id'], 'username'); $family = getuser($myrow['id'],'family'); $post_avatar = getuser($myrow['id'],'avatar'); ?> <div class='box'> <?php echo " <img src='/".$post_avatar."' width=50px border=0px>"?><?php echo " $username $family " ?> |<font color='#4aaee7' size='2px' > <?php echo $post_time; ?></font> <br/> 

displays incorrect information avatars, names and surnames. Help, what's the problem?

  • one
    deprecated This extension is deprecated since PHP 5.5.0 and will be removed in the future. Use MySQLi or PDO_MySQL instead. See also the MySQL instruction: API selection and the corresponding FAQ for more details. Alternatives to this function: mysqli_connect () PDO :: __ construct () - zb '
  • one
    and what outputs? what data in variables? What is returned for this request from the database? - IVsevolod

3 answers 3

 $username = **getuser**($myrow['id'], 'username'); $family = **getuser**($myrow['id'],'family'); $post_avatar = **getuser**($myrow['id'],'avatar'); 

(It does not correctly display the avatar and the surname and name of the avatar. HELP IN WHAT IS THE PROBLEM?)

View your getuser () function; maybe there is an error ..

  • function getuser ($ id, $ field) {$ query = mysql_query ("SELECT $ field FROM users WHERE id = '$ id'"); $ run = mysql_fetch_array ($ query); return $ run [$ field]; } Here is my function with friends that displays everything correctly, but with no comments. - andreykartavtsev

Probably need to be replaced:

 $myrow['id'] 

on

 $myrow[$id] 

    Error in the layout, it hardly concerns your problem, but correct it anyway.

     <div class='box'> <?php echo "<img src='/".$post_avatar."' style='border:0; width:50px;' alt='' />"?><?php echo $username." ".$family "; ?> |<span style="color:#4aaee7; font-size:8px;' > <?php echo $post_time; ?></span> <br/> 

    As for the error, tell me what it displays and what should output

    • Sorry for what I couldn’t answer for so long. There are 2 users here. They like id1 and id2, so here. I go through id1 and write at myself. That’s all mine: avatar.name.name, but if I’m writing to another user, it’s not mine, but its.avatar.name.name is andreykartavtsev