Code Issue

Meap

Don't need glasses if you C#
Nov 7, 2010
1,045
296
On my user homes I am trying to get the users friends to show but whenever I use this code for grabbing their friends, my page refuses to load, can anyone help with this?
Code:
<?php $getnew = mysql_query("SELECT * FROM users WHERE `id` IN (SELECT `user_one_id` FROM `messenger_friendships` WHERE `user_two_id`='$id') ORDER BY id DESC;"); while($new = mysql_fetch_array($getnew)) { ?>
 

JayC

Well-Known Member
Aug 8, 2013
5,505
1,401
Code:
<?php 
$getnew = mysql_query("SELECT * FROM users WHERE `id` IN (SELECT `user_one_id` FROM `messenger_friendships` WHERE `user_two_id`='$id') ORDER BY id DESC;"); while($new = mysql_fetch_array($getnew)) 
{ 
?>

You end your page with
Code:
<?php
}
?>
correct?
 

Meap

Don't need glasses if you C#
Nov 7, 2010
1,045
296
yeah I do why
 
nvm I fixed it, I forgot the extra one needed because of that statement, cheers
 
nevermind it doesnt work as well with plus database, it only gets like half of my friends list
 
May 1, 2015
470
154
Code:
$getfriend = mysql_query("SELECT * FROM users WHERE id ='".$friends['user_two_id']."'");
                if(mysql_num_rows($getfriend) > 0)
                {
                    $i++;
                    if($i == 1)
                    {
                     
                        echo '<li id="feed-friends">Your friend(s) are:<b><span> ';
                    }
                    $friend = mysql_fetch_array($getfriend);
echo htmlspecialchars($friend['username']).', ';
                }
            }
            if($i > 0)
echo '</b>'?>
 

JayC

Well-Known Member
Aug 8, 2013
5,505
1,401
Code:
$getfriend = mysql_query("SELECT * FROM users WHERE id ='".$friends['user_two_id']."'");
                if(mysql_num_rows($getfriend) > 0)
                {
                    $i++;
                    if($i == 1)
                    {
                    
                        echo '<li id="feed-friends">Your friend(s) are:<b><span> ';
                    }
                    $friend = mysql_fetch_array($getfriend);
echo htmlspecialchars($friend['username']).', ';
                }
            }
            if($i > 0)
echo '</b>'?>
It's nice when you copy code from a CMS but you missed half of it.
 

Users who are viewing this thread

Top