What on earth is wrong with it?

<?

Header("content-type: application/x-javascript");
$chatnames = file('http://client11.addonchat.com/scwho.pl?id=292747&plain=1');


$indx = count($chatnames);
$indxcom = $indx - 1;

if ($indx == 0){
echo "document.write(\"No one is in the chat room at the 

moment"\)"; 
}

else{
echo "document.write(\"<b>Members Chatting:</b>"\)";


  for($i = 0; $i < $indx; $i++) {

    $name = explode('      ', $chatnames[$i], 2);

    echo "document.write(\"$name[0]"\)";

    if ($i < $indxcom) {

   echo "document.write(\","\)"; 
}  

  }
}
?>


<script type="text/javascript" src="http://h1.ripway.com/Inny/chat.php"></script>

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Hi Inny, read the whole reply to find the error at its end. I'll keep the rest of my original post to show you my track of thoughts which could be helpful for you some other time.

Maybe fopen wrappers aren't enabled. (file('http://...)
Or maybe short_open_tag is off. (<?php versus <?)

Try placing this at the top and call it not with the <script> tag but directly:

error_reporting(255);
ini_set('display_errors','On');

Well, I just called it directly and there are run-time errors that tells you what's wrong:
http://h1.ripway.com/Inny/chat.php

It's difficult to count for me which line is the 13th but I guess you placed a backslash before parenthesis and not before quotation marks:

echo "document.write(\","\)";

You should use a text editor with syntax highlighting (e.g. http://www.pspad.com/). Even DaniWeb syntax highlighter would have pointed out the error for you.

Happy coding.

Your Absolutely Right! I did.
Unfortunately I discovered the main issue: The file no longer exist!

:D lol

Thanks for your help!

This article has been dead for over six months. Start a new discussion instead.