Well I have modified the top of the code a bit so that the code would work if the $user_id was blank. I tried both the $userid and $USER_ID and still nothing.
So I can ensure that its not an error with there being no userid or username.. Unless my code is wrong?
Here is the modified original code:
PHP Code:
global $vbulletin;
require_once('./global.php');
$con = mysql_connect ("xxxxxxx","xxxxxxx", "xxxxxxx");
mysql_select_db ("xxxxxxx");
$userid = intval($_COOKIE[bbuserid]);
$sql = @mysql_query("SELECT username FROM user WHERE userid=$userid");
while ($row = @mysql_fetch_array($sql)){
$name = $row['username'];
$icon = $row['icon'];
$color = $row['color'];
}
if($color == 0)
{
$color = "#989579";
}
if ($icon == '')
{
$icon = 'http://www.hiveworkshop.com/forums/images_all/chat_ranks/new/user.png';
}
if ($userid == ''){
$username = 'Guest';
}
I have also attempted to see if maybe another approach would work. Yet nothing. Again, unless I did something wrong?
PHP Code:
global $vbulletin;
require_once('./global.php');
//if (!isset($_SESSION['userid'])) $_SESSION['userid'] = rand(1, 24);
//$userid = $_SESSION['userid'];
$userid = $vbulletin->userinfo['userid'];
$username = $vbulletin->userinfo['username'];
if ($userid == ''){
$username = 'Guest';
}