I have an AJAX chat that I am trying to edit. Originally, the users are stored in a php file. I'm trying to make it get users from a database.

Here's the original users.php file: http://pastebin.com/mgbQjHyK
Here's what I've tried: http://pastebin.com/kXgVLuyG

Can someone tell me what I'm doing wrong?
[hr]
Here's the error that it outputs:

This page contains the following errors:

error on line 2 at column 1: Extra content at the end of the document
Below is a rendering of the page up to the first error.
[theres nothing displayed after this]

Recommended Answers

All 9 Replies

$users[$uid]['userName'] = '$username'; should be: $users[$uid]['userName'] = $username; No apostrophes around $username . Other than that, make sure that the AJAX_CHAT_XXX CONSTANTS you are using are defined.

Thanks and I fixed it, still have error though D:

The constants are correct.

are you including multiple files? If so, then check in the other files. After the corrections above, the file you posted should not be giving you any problems.

Also, check your error log file. If you are with a web host, ask them for the location of your log file.

one more suggestion - change:

$con = mysql_connect("localhost", "dannyf_admin", "mypasswordishere");
mysql_select_db("dannyf_test", $con);
$query = mysql_query("SELECT * FROM ajax_chat_users");
 
while($row = mysql_fetch_array($query)){

to:

$con = mysql_connect("localhost", "dannyf_admin", "mypasswordishere") or die(mysql_error());
mysql_select_db("dannyf_test", $con) or die(mysql_error());
$query = mysql_query("SELECT * FROM ajax_chat_users") or die(mysql_error());
 
while($row = mysql_fetch_assoc($query)){

I fixed all that, and I still have the problem.

If it helps find me a solution, this is the script I am using: https://blueimp.net/ajax/

Thanks in advance for a good solution (and thanks to everyone who has replied so far :)).

use parse functions to changing the type of file system i am also develop project using scripting language. so you will get some idea from by give below website:
<URL SNIPPED>

I don't understand, toplinecar...

error on line 2 at column 1

that doesn't tell on which file. The fact that I don't see the constants defined on the file you posted indicates that there are file being included in the "main" file. Thus, you need to find out which file is the one that actually has the problem. Look at your php log file as indicated previously.

I will check the log file and see if anything is there. The error I get isn't your typical PHP/apache error message, this looks like it was outputted by something the creator of the script made.

Edit: nothing in the error log file from cPanel...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.