Jump to content
Sign in to follow this  
djwins

Php Help Requested!

Recommended Posts

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!

Share this post


Link to post
Share on other sites

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. :unsure:

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...