Free Arcade Script
FAS Help => V1.x => : cravedgames August 21, 2009, 11:01:21 PM
-
Hello recently i have been styling the design for comments on my website and i was trying to add the users avatar and a link to their profile etc in their comments; Here is the code i am using at the moment for a link to their profile but it does not work :(
if($comments_on == 1){
$r = $db->query(sprintf('SELECT * FROM dd_comments WHERE gameid=\'%u\' AND approved=\'1\' ORDER BY date DESC LIMIT 3', $ID));
while($row = $db->fetch_row($r)){
$date = date('d-m-Y', $row['date']);
$rra = $db->fetch_row($db->query(sprintf('SELECT username FROM dd_users WHERE userid=\'%u\'', $row['commenter'])));
$useridl=$row['userid'];
$urlp = ''.$domain.'/index.php?action=showprofile&profile='.$useridl ;
if ( $row['commenter'] == '0' ) {$commenter='Guest';} else {$commenter=$rra['username'];};
echo '<b>Posted By:</b> <a href="'.$urlp.'">'.$commenter.'</a>';
Please Help me find out the code needed to fix this. thanks in advance
-
Try it this way instead
if($comments_on == 1){
$r = $db->query(sprintf('SELECT * FROM dd_comments WHERE gameid=\'%u\' AND approved=\'1\' ORDER BY date DESC LIMIT 3', $ID));
while($row = $db->fetch_row($r)){
$date = date('d-m-Y', $row['date']);
$rra = $db->fetch_row($db->query(sprintf('SELECT username FROM dd_users WHERE userid=\'%u\'', $row['commenter'])));
$useridl=$row['commenter'];
$urlp = ''.$domain.'/index.php?action=showprofile&profile='.$useridl ;
if ( $row['commenter'] == '0' ) {$commenter='Guest';} else {$commenter=$rra['username'];};
echo '<b>Posted By:</b> <a href="'.$urlp.'">'.$commenter.'</a>';
The only thing I changed is the row that says
$useridl=$row['userid'];
to say
$useridl=$row['commenter'];
Let me know how that works. If it does not, let me know the URL where I can see it and look at what it's doing or not doing.
-
I just took a look at you're site and I think all you're problem is, is the id.
try:
if($comments_on == 1){
$r = $db->query(sprintf('SELECT * FROM dd_comments WHERE gameid=\'%u\' AND approved=\'1\' ORDER BY date DESC LIMIT 3', $ID));
while($row = $db->fetch_row($r)){
$date = date('d-m-Y', $row['date']);
$rra = $db->fetch_row($db->query(sprintf('SELECT username FROM dd_users WHERE userid=\'%u\'', $row['commenter'])));
$useridl=$row['userid'];
$urlp = ''.$domain.'/index.php?action=showprofile&profile='.$useridl.'';
if ( $row['commenter'] == '0' ) {$commenter='Guest';} else {$commenter=$rra['username'];};
echo '<b>Posted By:</b> <a href="'.$urlp.'">'.$commenter.'</a>';
oh and for the avatars you could try:
if($comments_on == 1){
$r = $db->query(sprintf('SELECT * FROM dd_comments WHERE gameid=\'%u\' AND approved=\'1\' ORDER BY date DESC LIMIT 3', $ID));
while($row = $db->fetch_row($r)){
$date = date('d-m-Y', $row['date']);
$rra = $db->fetch_row($db->query(sprintf('SELECT username,avatarfile FROM dd_users WHERE userid=\'%u\'', $row['commenter'])));
$useridl=$row['userid'];
if($row['avatarfile']){
$useravatar=$row['avatarfile'];
}else{
$useravatar="default.jpg";
}
$urlp = ''.$domain.'/index.php?action=showprofile&profile='.$useridl.'';
if ($row['commenter'] == 0){
$commenter='Guest';
}else{
$commenter=$rra['username'];};
echo '<b>Posted By:</b> <a href="'.$urlp.'">'.$commenter.'<br />
<img src="'.$domain.'/avatars/$useravatar" /></a>';
I think that should work.. ;)
-
Sorry, None of these codes seem to work :( i think its different when working with comments
-
What's the URL so I can take a look at what it's doing?
-
The code I just gave you above, I just tried it on an unmodified copy of the script on the page where you play the game and it worked on our server. If you have modified the page it might be something in the modifications that is interefering, or it might be server specific, or it could be something else. I would need to see it in action to know what the problem is. If you want to PM me your URL and FTP log on details I would be happy to take a look at it. I've been back and forth between the computer and some other things I have going on here, but I would try to get it done as soon as I could. Or I can make up a zip file of the one I did and you can try it.
-
Here, when I posted above, my box was busy making a rather large zip file and I could not work on both at the same time. It got done faster than I though so I made a zip of the new play.php file. You can unzip it and drop it into /pages and see if it works like you want.
Back up your old one first!
Let me know if it works for you.
-
Well using "Commenter" to get the user id seams to work but i still cant get the users avatar
-
OK, now that we know that works I updated the file to include avatars. They only show if the member has them activated though, other wise it is left blank.
The file has been updated, go ahead and redownload it and try it again. Let me know how it works.
-
Still doesnt seam to work :(
-
It doesn't work with the new file? It works on the demo as you can see here
http://demo.freearcadescript.net/play/29-Mario-Karte.html
If it still does not work on your server, I would have to look it over. Send me the FTP/cPanel log in details and I'll see what I can do.
-
:(