Problem displaying phpbb avatars outside of forum

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
mareksl
Forum Newbie
Posts: 18
Joined: Tue Mar 08, 2011 12:24 pm
Location: Poland

Problem displaying phpbb avatars outside of forum

Post by mareksl »

Hey!
I have successfully integrated some of phpbb's functions with my website, such as the login system and a part of the user profiles.
The problem is, when I try displaying the avatars of the users, the avatar does not show up.
First of all, I checked, and the filename of the avatar in the database is different from the actual filename in the "forum/images/avatars/upload" directory.
Then, even when I manually tried to correct the filename (just to try it out) it gives me a 403 error.
How can I display the user avatar on my site successfully?
Here is my current code:

Code: Select all

<?php
$user = $_GET["user"];
$con = mysql_connect("localhost","***","***");
if (!$con) {die('Could not connect: ' . mysql_error());}
mysql_select_db("db_kitchentube", $con);
$result = mysql_query("SELECT * FROM phpbb_users WHERE username_clean = '$user'");
And later:

Code: Select all

<img class="user" src="forum/images/avatars/upload/<?php echo $row['user_avatar'] ?>" width="90px" height="90px" alt="pic" /></a>
Thanks!
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Problem displaying phpbb avatars outside of forum

Post by McInfo »

Can you use phpBB's download script?

Code: Select all

forum/download/file.php?avatar=0_1234567890.jpg
User avatar
mareksl
Forum Newbie
Posts: 18
Joined: Tue Mar 08, 2011 12:24 pm
Location: Poland

Re: Problem displaying phpbb avatars outside of forum

Post by mareksl »

Thanks, it's working! :)
Post Reply