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: -
<?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 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.
Heya, RoxxorzIt. Welcome to TSDN!
Please use CODE tags when posting source 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.
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 missed something obvious.
|
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.
|
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
|
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
|
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.
| |
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";
|
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.
|
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
|
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.
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
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...
| |