PDA

View Full Version : stuck on a peace of code (get vb username)


ageurtse
23 Dec 2009, 18:00
Why does the code below not work.

when i put echo 'start '. $vbcheck['userid'].' end <br>' outside the function and in the head part it works. but in the function i can't get it to work.

why is this not working, and how can i get it to work.



<?php
$curdir = getcwd ();
chdir('C:/UsbWebserver/Root');
require_once('C:/UsbWebserver/Root/global.php');
chdir('C:/UsbWebserver/Root/chat');

$vbcheck = $vbulletin->userinfo;
?>

<?php

// Returns an array of user details, or false depending on whether user's cookies are valid.
function usercheck()
{
echo 'start '. $vbcheck['userid'].' end <br>';
}
?>

Lynne
23 Dec 2009, 18:14
Where are you putting this code? Right now, that code isn't going to produce a thing because you haven't called the function usercheck.

ageurtse
23 Dec 2009, 18:18
yes i now that, i have found the problam.

i put in the function the following line global $vbulletin;
and now it works great.

Lynne
23 Dec 2009, 18:40
You may want to try vB::$vbulletin->whatever instead of making the variable global.