<?php
  //
  print "<h1>MySQL Connection Limit Test</h1>\n";

  // display errors
  error_reporting(E_ALL);  // display all errors
  ini_set('display_errors', '1');
  ini_set('display_startup_errors', '1');
  ini_set('html_errors', '0');      // don't output html links in error messages

  // mysql info
  $hostname = "localhost";
  $username = "root";
  $password = "";

  // connect
  $DBH = @mysql_connect($hostname, $username, $password);
  if (!$DBH) { print "Program was unable to connect to the MySQL on '$hostname'.\nThe reason given was: " . mysql_error(); }

  // get connection limits
  $query   = "SELECT @@max_connections, @@max_user_connections";
  $result  = mysql_query($query) or die("MySQL Error: ". htmlspecialchars(mysql_error()) . "\n");
  list($maxConnections, $maxUserConnections) = mysql_fetch_row($result);
  if (is_resource($result)) { mysql_free_result($result); }

  // show limits
  print "MySQL <a href='http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_max_connections'>max_connections</a>: " .$maxConnections. "<br/>\n";
  print "MySQL <a href='http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_max_user_connections'>max_user_connections</a>: " .$maxUserConnections. "<br/>\n";
  print "<p>Done!";

?>
