1
Xanavieaus
getting a variable for currently logged in user... is it possible?
  • 2005/10/15 20:02

  • Xanavieaus

  • Just popping in

  • Posts: 22

  • Since: 2005/10/1


I'm trying to make a script that enables people to choose between a flash banner and a plain image banner. In it, i'm making it read the database to find out exactly what the user has selected. To achieve this, I have to finish the following code:

$fbannerenabled = mysql_query("SELECT 'flashbanner' FROM 'dnet_user_profile' WHERE 'profileid' = ''");

Where is, is where I need to be able to somehow get a variable that indicates which user you are logged in as.

I always thought this was $uid;, but that didn't work.

I have created a script called "flashbanner.php" which resides in the "/include" folder, and is included from "header.php".

Who is able to help me?

2
smdcom
Re: getting a variable for currently logged in user... is it possible?

You can try this:

include("mainfile.php");

global 
$xoopsDB$xoopsUser;

$query $xoopsDB->query("SELECT flashbanner FROM dnet_user_profile WHERE profileid = "".$xoopsUser->uid().""");
while(
$row $xoopsDB->fetchRow($query)){
   echo 
$row['flashbanner'];
   
// to fetch result
}


Good Luck!

SMD

3
Xanavieaus
Re: getting a variable for currently logged in user... is it possible?
  • 2005/10/15 20:35

  • Xanavieaus

  • Just popping in

  • Posts: 22

  • Since: 2005/10/1


Thanks, but now I get this:

Fatal error: Call to a member function on a non-object in d:\htdocs\dragyn\include\flashbanner.php on line 7

when I'm logged out....

4
smdcom
Re: getting a variable for currently logged in user... is it possible?

what's on line 7?

5
Xanavieaus
Re: getting a variable for currently logged in user... is it possible?
  • 2005/10/15 20:41

  • Xanavieaus

  • Just popping in

  • Posts: 22

  • Since: 2005/10/1


$query = $xoopsDB->query("SELECT flashbanner FROM dnet_user_profile WHERE profileid = \"".$xoopsUser->uid()."\"");

It might have something to do with the fact that this value becomes NULL when you are logged out.

6
smdcom
Re: getting a variable for currently logged in user... is it possible?

Oh.. i didn't notice you put the flashbanner.php in /include folder. Change your mainfile path to

include XOOPS_ROOT_PATH."/mainfile.php";

7
Xanavieaus
Re: getting a variable for currently logged in user... is it possible?
  • 2005/10/15 20:49

  • Xanavieaus

  • Just popping in

  • Posts: 22

  • Since: 2005/10/1


Didn't help at all... same error :(

8
smdcom
Re: getting a variable for currently logged in user... is it possible?

I think it's still not include mainfile.php

Try put your flashbanner.php at XOOPS_ROOT and use:

include("mainfile.php");

9
Xanavieaus
Re: getting a variable for currently logged in user... is it possible?
  • 2005/10/15 21:11

  • Xanavieaus

  • Just popping in

  • Posts: 22

  • Since: 2005/10/1


Still the same error...
I've looked in the mainfile.php, and $xoopsUser->uid() is not defined or even mentioned anywhere in the file.

10
smdcom
Re: getting a variable for currently logged in user... is it possible?

$xoopsUser is global variable. We've to include mainfile.php in order to use it. Can u give me your full code or pm me the full code of flashbanner.php.

Login

Who's Online

382 user(s) are online (287 user(s) are browsing Support Forums)


Members: 0


Guests: 382


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits