djwins Posted August 1, 2003 Posted August 1, 2003 Let me preface this by saying im a total rookie when it comes to this stuff... I'm trying to add this little php script to my website which should display the number of users currently in my chat room. Unfortunately, when I added it to my site, nothing happened. No error message, no text displayed...nothing. Any help would be greatly appreciated. I looked in the SQL manager just to confirm that the user name and database name were correct, and they were. ><?php @ $db = mysql_pconnect("localhost", "cheapas_cheapyd", "PASSWORD"); if (!$db) { echo "MySQL ERROR: Could not connect to the Chat DB. Please try later."; exit; } mysql_select_db("cheapas_pchat1"); $query = "SELECT DISTINCT username FROM c_users"; $result = mysql_query($query); $num_results = mysql_num_rows($result); echo "There are ".$num_results." users in the chat."; ?> Thanks in advance! Quote
cmuskett Posted August 1, 2003 Posted August 1, 2003 I had the same problem with the counter on my site. I then found out that the page the counter was on had to be a .php extension, such as index.php. Then the counter showed up. Quote
surefire Posted August 1, 2003 Posted August 1, 2003 I believe that you are getting no error messages because after TCH upgraded to the latest version of PHP, they temporarily suppressed most error messages. What I would do, to debug your code, would be to turn off the bottom two thirds of the script. Right here exit; } I would put print ("testing"); and then /* To start to comment out the bottom part of the script. Then at the bottom of the script put */ ?> So the script would look like <?php@ $db = mysql_pconnect("localhost", "cheapas_cheapyd", "PASSWORD"); if (!$db) { echo "MySQL ERROR: Could not connect to the Chat DB. Please try later."; exit; } print("testing"); /* mysql_select_db("cheapas_pchat1"); $query = "SELECT DISTINCT username FROM c_users"; $result = mysql_query($query); $num_results = mysql_num_rows($result); echo "There are ".$num_results." users in the chat."; */ ?> Upload it, see if it prints 'testing'. If so, then move the print statement further down until you get a spot that doesn't work. Then you know where your probelm is. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.