The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Custom chat not showing Usernames?
Hello there I have a custom chat that functions properly; however, it doesnt properly display the usernames. Can someone help me with this?
Online Demo Notice how when you type, it doesnt show the username. such as below Code:
[02:38:05] This is the message Code:
[02:38:05] Username: This is the message PHP Code:
|
#2
|
|||
|
|||
Here is a screenshot of the issue.
The conding header for the non-boxed area of the screenshot is shown below: Code:
error_reporting(0); session_start(); header('Cache-control: private'); // IE6 fix header("Content-Type: text/html; charset=utf-8"); if (!isset($_SESSION['USER_ID'])) $_SESSION['USER_ID'] = rand(1, 24); $USER_ID = $_SESSION['USER_ID']; session_write_close(); ob_flush(); flush(); Code:
error_reporting(0); session_start(); header('Cache-control: private'); // IE6 fix header("Content-Type: text/html; charset=utf-8"); $con = mysql_connect ("xxxxxx","xxxxxx", "xxxxxx"); mysql_select_db ("aaronxxxxxx_vbulletin"); $userid = intval($_COOKIE[bbuserid]); $sql = @mysql_query("SELECT username FROM user WHERE userid=$USER_ID"); while ($row = @mysql_fetch_array($sql)){ $username = $row['username']; } session_write_close(); ob_flush(); flush(); |
#3
|
||||
|
||||
You have this:
Code:
$userid = intval($_COOKIE[bbuserid]); $sql = @mysql_query("SELECT username FROM user WHERE userid=$USER_ID"); And why are you doing a while loop when you are only expecting one row returned? |
#4
|
|||
|
|||
I am not entirely sure whether its $userid or $USER_ID but when I changed it to $userid, the chat doesnt work no more. It doesnt connect the user. So it must be $USER_ID.
As for the while loop, I did that because I will code the rest where I will add $icon = $row['icon']; $color = $row['color']; So each user will have a custom icon, if none then they will have a generic icon set for their particularity usergroup. The color is for the text color of each usergroup's username. So "User 1" as an Admin will be Blue, where as "User2" a regular member, will just be white. |
#5
|
|||
|
|||
Quote:
Or not. |
#6
|
|||
|
|||
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:
PHP Code:
|
#7
|
|||
|
|||
Is your php file included (or "required") in another file, or is it supposed to be "stand-alone". I'm not sure if you're showing all the code in what you posted above, but if that file isn't being included in another vbulletin file, then you need to define some things before including global.php. If it is being included, then you probably don't need to include global.php.
Your original code had "error_reporting(0);" and some '@'s at the beginning of some function calls. You might want to remove those, at least temporarily, so you can see any PHP errors that you might be getting. |
#8
|
|||
|
|||
Well theres 3 files involved. chat.php, chat.txt and chat.htm Everything I have showed you is the complete code. Chat.txt as you can imagine, is just the file it writes to and displays.
Below is the chat.htm: PHP Code:
|
#9
|
||||
|
||||
This will not do anything:
Code:
$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']; } |
#10
|
|||
|
|||
I think you want error_reporting(-1) to turn on all errors.
Quote:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|