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_string() 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:
faultCode0faultStringFatal error:Call to a member function acl_get() on a non-object in /home/vol1/phpnet.us/g/gfgezpk/www/forums/includes/functions_content.php on line 1119
And here's my script: -
<?php
-
define('IN_PHPBB', true);
-
include("forums/includes/functions_content.php");
-
-
$connection = mysql_connect("*****", "*****", "*****");
-
-
if (!$connection) {die ("An error has occured while attempting to access the MySQL database");}
-
-
mysql_selectdb('*****') or die(mysql_error());
-
-
$query = mysql_query("SELECT * FROM `phpbb_posts`");
-
-
while ($row = mysql_fetch_array($query)) {
-
$username;
-
$user = get_username_string('username', $row['poster_id'], $row['post_username']);
-
echo "Posted by: " . $user;
-
}
-
mysql_close();
-
?>
-
-
Also, here's the function:
-
/**
-
* Get username details for placing into templates.
-
*
-
* @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)
-
* @param int $user_id The users id
-
* @param string $username The users name
-
* @param string $username_colour The users colour
-
* @param string $guest_username optional parameter to specify the guest username. It will be used in favor of the GUEST language variable then.
-
* @param string $custom_profile_url optional parameter to specify a profile url. The user id get appended to this url as &u={user_id}
-
*
-
* @return string A string consisting of what is wanted based on $mode.
-
*/
-
function get_username_string($mode, $user_id, $username, $username_colour = '', $guest_username = false, $custom_profile_url = false)
-
{
-
global $phpbb_root_path, $phpEx, $user, $auth;
-
-
$profile_url = '';
-
$username_colour = ($username_colour) ? '#' . $username_colour : '';
-
-
if ($guest_username === false)
-
{
-
$username = ($username) ? $username : $user->lang['GUEST'];
-
}
-
else
-
{
-
$username = ($user_id && $user_id != ANONYMOUS) ? $username : ((!empty($guest_username)) ? $guest_username : $user->lang['GUEST']);
-
}
-
-
// Only show the link if not anonymous
-
if ($mode != 'no_profile' && $user_id && $user_id != ANONYMOUS)
-
{
-
// Do not show the link if the user is already logged in but do not have u_viewprofile permissions (relevant for bots mostly).
-
// For all others the link leads to a login page or the profile.
-
if ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile'))
-
{
-
$profile_url = '';
-
}
-
else
-
{
-
$profile_url = ($custom_profile_url !== false) ? $custom_profile_url . '&u=' . (int) $user_id : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . (int) $user_id);
-
}
-
}
-
else
-
{
-
$profile_url = '';
-
}
-
-
switch ($mode)
-
{
-
case 'profile':
-
return $profile_url;
-
break;
-
-
case 'username':
-
return $username;
-
break;
-
-
case 'colour':
-
return $username_colour;
-
break;
-
-
case 'no_profile':
-
case 'full':
-
default:
-
-
$tpl = '';
-
if (!$profile_url && !$username_colour)
-
{
-
$tpl = '{USERNAME}';
-
}
-
else if (!$profile_url && $username_colour)
-
{
-
$tpl = '<span style="color: {USERNAME_COLOUR};" class="username-coloured">{USERNAME}</span>';
-
}
-
else if ($profile_url && !$username_colour)
-
{
-
$tpl = '<a href="{PROFILE_URL}">{USERNAME}</a>';
-
}
-
else if ($profile_url && $username_colour)
-
{
-
$tpl = '<a href="{PROFILE_URL}" style="color: {USERNAME_COLOUR};" class="username-coloured">{USERNAME}</a>';
-
}
-
-
return str_replace(array('{PROFILE_URL}', '{USERNAME_COLOUR}', '{USERNAME}'), array($profile_url, $username_colour, $username), $tpl);
-
break;
-
}
-
}
3 8094 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_string() 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.
Heya, RoxxorzIt. Welcome to TSDN!
Please use CODE tags when posting source code:
get_username_string() 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: - 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: - mysql_query("SELECT `username` FROM `phpbb_users` WHERE `user_id` = $row['poster_id']");
pbmods 5,821
Recognized Expert Expert
Heya, RoxxorzIt.
Try this: -
mysql_query("SELECT `username` FROM `phpbb_users` WHERE `user_id` = '{$row['poster_id']}' LIMIT 1");
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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...
|
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...
|
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...
| |
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:...
|
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...
|
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...
|
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....
|
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,...
|
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,...
| |
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
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 ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |