473,659 Members | 2,663 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHPBB3 get_username_st ring() function woes

2 New Member
Alright, all I'm trying to do at the moment is display who posted a topic from a page entirely separate from PHPBB. The problem is, it seems no matter what I do, I just can't find a way to do so.

Then, I heard about the get_username_st ring() function.

Well, it won't work for me and I don't even know why...

First of all, I have no idea what parameters need to be passed to it aside from the user_id of the account in question. Here's what I have written, if anyone could help me out I'd REALLY appreciate it, I've been stuck exactly right where I am for at least 15 hours...

Here's my error:
faultCode0fault StringFatal error:Call to a member function acl_get() on a non-object in /home/vol1/phpnet.us/g/gfgezpk/www/forums/includes/functions_conte nt.php on line 1119

And here's my script:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. define('IN_PHPBB', true);
  3. include("forums/includes/functions_content.php");
  4.  
  5. $connection = mysql_connect("*****", "*****", "*****");
  6.  
  7. if (!$connection) {die ("An error has occured while attempting to access the MySQL database");}
  8.  
  9. mysql_selectdb('*****') or die(mysql_error());
  10.  
  11. $query = mysql_query("SELECT * FROM `phpbb_posts`");
  12.  
  13. while ($row = mysql_fetch_array($query)) {
  14.     $username;
  15.     $user = get_username_string('username', $row['poster_id'], $row['post_username']);
  16.     echo "Posted by: " . $user;
  17. }
  18. mysql_close();
  19. ?>
  20.  
  21. Also, here's the function:
  22. /**
  23. * Get username details for placing into templates.
  24. *
  25. * @param string $mode Can be profile (for getting an url to the profile), username (for obtaining the username), colour (for obtaining the user colour), full (for obtaining a html string representing a coloured link to the users profile) or no_profile (the same as full but forcing no profile link)
  26. * @param int $user_id The users id
  27. * @param string $username The users name
  28. * @param string $username_colour The users colour
  29. * @param string $guest_username optional parameter to specify the guest username. It will be used in favor of the GUEST language variable then.
  30. * @param string $custom_profile_url optional parameter to specify a profile url. The user id get appended to this url as &amp;u={user_id}
  31. *
  32. * @return string A string consisting of what is wanted based on $mode.
  33. */
  34. function get_username_string($mode, $user_id, $username, $username_colour = '', $guest_username = false, $custom_profile_url = false)
  35. {
  36.     global $phpbb_root_path, $phpEx, $user, $auth;
  37.  
  38.     $profile_url = '';
  39.     $username_colour = ($username_colour) ? '#' . $username_colour : '';
  40.  
  41.     if ($guest_username === false)
  42.     {
  43.         $username = ($username) ? $username : $user->lang['GUEST'];
  44.     }
  45.     else
  46.     {
  47.         $username = ($user_id && $user_id != ANONYMOUS) ? $username : ((!empty($guest_username)) ? $guest_username : $user->lang['GUEST']);
  48.     }
  49.  
  50.     // Only show the link if not anonymous
  51.     if ($mode != 'no_profile' && $user_id && $user_id != ANONYMOUS)
  52.     {
  53.         // Do not show the link if the user is already logged in but do not have u_viewprofile permissions (relevant for bots mostly).
  54.         // For all others the link leads to a login page or the profile.
  55.         if ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile'))
  56.         {
  57.             $profile_url = '';
  58.         }
  59.         else
  60.         {
  61.             $profile_url = ($custom_profile_url !== false) ? $custom_profile_url . '&amp;u=' . (int) $user_id : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&amp;u=' . (int) $user_id);
  62.         }
  63.     }
  64.     else
  65.     {
  66.         $profile_url = '';
  67.     }
  68.  
  69.     switch ($mode)
  70.     {
  71.         case 'profile':
  72.             return $profile_url;
  73.         break;
  74.  
  75.         case 'username':
  76.             return $username;
  77.         break;
  78.  
  79.         case 'colour':
  80.             return $username_colour;
  81.         break;
  82.  
  83.         case 'no_profile':
  84.         case 'full':
  85.         default:
  86.  
  87.             $tpl = '';
  88.             if (!$profile_url && !$username_colour)
  89.             {
  90.                 $tpl = '{USERNAME}';
  91.             }
  92.             else if (!$profile_url && $username_colour)
  93.             {
  94.                 $tpl = '<span style="color: {USERNAME_COLOUR};" class="username-coloured">{USERNAME}</span>';
  95.             }
  96.             else if ($profile_url && !$username_colour)
  97.             {
  98.                 $tpl = '<a href="{PROFILE_URL}">{USERNAME}</a>';
  99.             }
  100.             else if ($profile_url && $username_colour)
  101.             {
  102.                 $tpl = '<a href="{PROFILE_URL}" style="color: {USERNAME_COLOUR};" class="username-coloured">{USERNAME}</a>';
  103.             }
  104.  
  105.             return str_replace(array('{PROFILE_URL}', '{USERNAME_COLOUR}', '{USERNAME}'), array($profile_url, $username_colour, $username), $tpl);
  106.         break;
  107.     }
  108. }
Oct 28 '07 #1
3 8114
pbmods
5,821 Recognized Expert Expert
Heya, RoxxorzIt. Welcome to TSDN!

Please use CODE tags when posting source code:

[CODE=php]
PHP code goes here.
[/CODE]

get_username_st ring() only works within phpbb (it requires the auth and session classes to be loaded).

Your best bet is to write a separate query to retrieve this data.
Oct 28 '07 #2
RoxxorzIt
2 New Member
Heya, RoxxorzIt. Welcome to TSDN!

Please use CODE tags when posting source code:

Expand|Select|Wrap|Line Numbers
  1. PHP code goes here.
  2.  
get_username_st ring() only works within phpbb (it requires the auth and session classes to be loaded).

Your best bet is to write a separate query to retrieve this data.
Thanks for the tip and welcoming!

I would like to write a separate query, but for some reason I get an error when attempting to include a variable received from any other query. It says it can't convert it to a string, but shouldn't it already be a string?

Like if I write a query to compare a poster_id with a user_id, I'd try to first get the poster_id like:

Expand|Select|Wrap|Line Numbers
  1. mysql_query("SELECT * FROM `phpbb_posts` WHERE `forum_id` = 4 LIMIT 0,5");
and pass the $row['poster_id'] variable to another query which says:

Expand|Select|Wrap|Line Numbers
  1. mysql_query("SELECT `username` FROM `phpbb_users` WHERE `user_id` = $row['poster_id']");
Oct 29 '07 #3
pbmods
5,821 Recognized Expert Expert
Heya, RoxxorzIt.

Try this:
Expand|Select|Wrap|Line Numbers
  1. mysql_query("SELECT `username` FROM `phpbb_users` WHERE `user_id` = '{$row['poster_id']}' LIMIT 1");
  2.  
Oct 29 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
1713
by: Mark | last post by:
O, woe is me, to have seen what I have seen, see what I see! (That's Shakespeare for those who were wondering what I'm on about) I am "having fun" with cookies. And I wonder if I have missed something obvious.
0
1520
by: Cedric | last post by:
This is a 3 weeks old problem, but having found a solution (and having looked for one here, finding only this message), I'm replying now. From: Jive (someone@microsoft.com) Subject: Upgrade woes: Numeric, gnuplot, and Python 2.4 Date: 2004-12-11 18:45:10 PST > Here's my sitch: > > I use gnuplot.py at work, platform Win32. > I want to upgrade to Python 2.4.
3
3451
by: Angel Cat | last post by:
Trying to get my jobs to send mail when job fails. Should be easy but it's giving me headache Had a whole slew of issues. Outlook is installed with a n outlook mail profile set up that can send mail in outlook. I can create a SendMail DTS and execute it to send mail Email works in these scenarios 1. I create a DTS package in SQL Server with just SendMail with the same Profile "ABC" and click Execute and it sends
2
1829
by: Andrew Thompson | last post by:
- NN 4.78 rendering woes, links at far left - I am trying to rework an old site, make it valid html and css, improving the x-browser and 'older browser' compatibility. My efforts so far, have been abysmal. See, for example, this screen shot of the very simple home page, it is not even 10% finished, but I have already run into problems. http://www.physci.org/test/xbrowser/nn478home01.png
15
3482
by: Albert | last post by:
Hi, I need to pass a pointer-to-member-function as a parameter to a function which takes pointer-to-function as an argument. Is there any way to do it besides overloading the function? Here is a small program I wrote to check if I could get the address of the function from the member-function-pointer, so that I could pass it to the function as a normal function-pointer.
1
1132
by: DennyLoi | last post by:
Hi Everyone, I have a problem with my javascript code. I am trying to pass a parameter to the checkAnswer function during using the onClick event handler. I wrote the following lines of code: var option2= document.createElement("input"); option2.type = "button"; option2.name = alldetails; option2.id = "test123";
0
1955
by: emalcolm_FLA | last post by:
Hello and TIA for your consideration. I have created several db's for a non-profit and they want custom navigation buttons to display "You are on the first record, last record, etc". With this ng help I've created code for all except the add new record command button. If I create individual sub functions behind each form, no problem. The problem is I am trying to create a re-usable module.
3
1526
by: willo | last post by:
Greetings all, I have run into a small problem with my understanding of some C++ language syntax, and seek some clarification. Below is a condensed version of some code I'm having difficulty with: =============================================================== #include <cstddef// size_t
0
1175
by: daemonsvk | last post by:
Hi, I have an c# app and I want the app to connect to the phpbb3 forum, login in, and download the list of topics. And here's my problem, I tried to connect to the forum with HttpWebRequest. But there is an auto redirection after the login. The response was the login page. So I think the forum sends a cookie which i don't know how to handle. Does anyone had this problem? Thanks for all your ideas.
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8330
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8850
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6178
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.