PDA

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


ageurtse
12-23-2009, 05:00 PM
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
12-23-2009, 05:14 PM
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
12-23-2009, 05:18 PM
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
12-23-2009, 05:40 PM
You may want to try vB::$vbulletin->whatever instead of making the variable global.