1

Topic: Show punbb user in joomla module.

PunBB version 1.2.17

I would like to create a Joomla 1.5 module which shows the punBB username. I have been looking at:
http://dev.joomla.org/component/option, … llo_world/

I have then tried to put the following code in the module file, helper file and default.php (/tmpl/), but I get the error below.
-Fatal error: Call to a member function query() on a non-object in /var/www/...site.../forum/include/functions.php on line 125

If I put the code in another file, and just use a wrapper it works.

define('PUN_ROOT', './forum/');
require PUN_ROOT.'include/common.php';
define('PUN_QUIET_VISIT', 1);

echo 'Logged in as: <b>'.pun_htmlspecialchars($pun_user['username']).'</b>';

2

Re: Show punbb user in joomla module.

Is there any other way to get the username?

3

Re: Show punbb user in joomla module.

it's pretty weird... can anyone elaborate what the error means? sad

4 (edited by quaker 2008-11-27 23:26)

Re: Show punbb user in joomla module.

you need to create a database query for the username....

the code doesn't know where to get the username from...

Q

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

5

Re: Show punbb user in joomla module.

sry forgot to mention, that before the above code is the following

$db = mysql_connect("server", "user", "password")or die("error message!");
mysql_select_db("dbname",$db)or die("error message 2!");

and. it works if I just create a .php page with the code, but when it's incorporated in a joomla module it doesn't (above error), the db is the same for both punbb and Joomla hmm

Re: Show punbb user in joomla module.

Variable db  is a link identifier of MySQL connection for Joomla, for PunBB - its object for SQL-quires. Its initialization happens in file PUN_ROOT.include/common.php.   
This error mean that you call method "query" of variable, that is not an object. You don't need to do following for getting results:

$db = mysql_connect("server", "user", "password")or die("error message!");
mysql_select_db("dbname",$db)or die("error message 2!");

Also after line

echo 'Logged in as: <b>'.pun_htmlspecialchars($pun_user['username']).'</b>';

add this two lines to close connections for punbb:

$db->end_transaction();
$db->close();

Don't forget to recreate connection for Joomla.

7

Re: Show punbb user in joomla module.

I still get the same error.
I have tried to remove the db connection, both with or without the close connection lines, rename the db connection variable (-> $db_pun so it doesn't conflict with Joomla's), pretty much every option available with the above code lines...still same error hmm don't know what I'm doing wrong... sad

Re: Show punbb user in joomla module.

You want to say that you rename $db to $db_pun in 'include/common.php'? It's not a good way. Place code were you have problem here or send an e-mail to me

9

Re: Show punbb user in joomla module.

Slavok wrote:

You want to say that you rename $db to $db_pun in 'include/common.php'? It's not a good way. Place code were you have problem here or send an e-mail to me

The code is the above just pasted into the hello world module tutorial in #0

If I use some other php code instead it works, but the code in #0 doesn't and give the mentioned error. hmm