Php Help Requested!

liunx

Guest
Let me preface this by saying im a total rookie when it comes to this stuff...<br /><br />I'm trying to add this little php script to my <a href="http://www.cheapassgamer.com" target="_blank">website</a> which should display the number of users currently in my chat room.<br />Unfortunately, when I added it to my site, nothing happened. No error message, no text displayed...nothing.<br />Any help would be greatly appreciated.<br />I looked in the SQL manager just to confirm that the user name and database name were correct, and they were.<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><?php<br />@ $db = mysql_pconnect("localhost", "cheapas_cheapyd", "PASSWORD");<br />if (!$db)<br />{<br />   echo "MySQL ERROR: Could not connect to the Chat DB. Please try later.";<br />   exit;<br />}<br />mysql_select_db("cheapas_pchat1");<br /> <br />$query = "SELECT DISTINCT username FROM c_users";<br />$result = mysql_query($query);<br />$num_results = mysql_num_rows($result);<br /> <br />echo "There are ".$num_results." users in the chat.";<br />?><!--c2--></div><!--ec2--><br /><br />Thanks in advance!<!--content-->
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. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><!--content-->
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.<br /><br />What I would do, to debug your code, would be to turn off the bottom two thirds of the script. Right here<br /><br /> exit;<br />}<br /><br />I would put<br /><br />print ("testing");<br /><br />and then <br /><br />/*<br /><br />To start to comment out the bottom part of the script.<br /><br />Then at the bottom of the script put <br /><br />*/<br />?><br /><br />So the script would look like<br /><br /><br /><!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec--><?php<br />@ $db = mysql_pconnect("localhost", "cheapas_cheapyd", "PASSWORD");<br />if (!$db)<br />{<br />  echo "MySQL ERROR: Could not connect to the Chat DB. Please try later.";<br />  exit;<br />}<br />print("testing");<br />/*<br />mysql_select_db("cheapas_pchat1");<br /><br />$query = "SELECT DISTINCT username FROM c_users";<br />$result = mysql_query($query);<br />$num_results = mysql_num_rows($result);<br /><br />echo "There are ".$num_results." users in the chat.";<br />*/<br />?><!--QuoteEnd--></div><!--QuoteEEnd--><br />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.<!--content-->
 
Top