- <?
- /**
- * Used to perform a 'Hello World' query against the database
- *
- * @package db
- * @filesource
- * @see HTML_DB_DATABASE_PATH.'/Hello.php'
- * @copyright (c) http://Finn-Rasmussen.com
- * @license http://Finn-Rasmussen.com/license/ myPHP License conditions
- * @author http://Finn-Rasmussen.com
- * @version 1.9
- * @since 21-oct-2005
- */
-
- $host = 'localhost'; // i.e. localhost
- $username = 'username';
- $password = 'password';
- $database = 'mysql'; // Database must exist
- $sql = 'SELECT * FROM user'; // Table must exist
-
- print "<html><head><title>Hello.php $host</title></head><body>\r\n";
- print "<h4>Expected result</h4>\r\n";
- print "mysql_connect($host,$username,$password) : OK<br />\r\n";
- print "mysql_select_db($database,Resource id #1) : OK<br />\r\n";
- print "mysql_query(SELECT * FROM user,Resource id #1) : (x) OK<br />\r\n";
- print "mysql_close(Resource id #1) : OK<br />\r\n";
- print "<hr />\r\n";
- print "<h4>Found result</h4>\r\n";
- $error = false; // Expect no errors
-
- print "mysql_connect($host,$username,$password) : ";
- $db = mysql_connect($host,$username,$password);
- if ($db) {
- print "OK<br />\r\n";
- } else {
- print "<b>Failed</b><br />\r\n";
- $error = true;
- }
-
- if ($db) {
- print "mysql_select_db($database,$db) : ";
- $rc = mysql_select_db($database,$db);
- if ($rc) {
- print "OK<br />\r\n";
- } else {
- print "<b>Failed</b><br />\r\n";
- $error = true;
- }
-
- print "mysql_query($sql,$db) : ";
- $rc = mysql_query($sql,$db);
- if ($rc) {
- print '('.mysql_num_rows($rc).") OK<br />\r\n";
- } else {
- print "<b>Failed</b><br />\r\n";
- $error = true;
- }
-
- print "mysql_close($db) : ";
- $rc = mysql_close($db);
- if ($rc) {
- print "OK<br />\r\n";
- } else {
- print "<b>Failed</b><br />\r\n";
- $error = true;
- }
- }
- if ($error) {
- print "<hr />\r\nmySQL <b>Failed</b>, please check you mySQL configuration:<br />\r\n";
- print "<ul>\r\n";
- print "<li>host: $host</li>\r\n";
- print "<li>username: $username</li>\r\n";
- print "<li>password: $password</li>\r\n";
- print "<li>database: $database (note: database must exist)</li>\r\n";
- print "<li>sql: $sql (note: table must exist)</li>\r\n";
- print "</ul>\r\n";
- } else {
- print "<hr />\r\n<b>Congratulation</b>, your mySQL is up and running<br />\r\n";
- print "<ul>\r\n";
- print "<li>host: $host</li>\r\n";
- print "<li>username: $username</li>\r\n";
- print "<li>password: $password</li>\r\n";
- print "<li>database: $database (note: database must exist)</li>\r\n";
- print "<li>sql: $sql (note: table must exist)</li>\r\n";
- print "</ul>\r\n";
- }
- print "</body></html>\r\n";
- ?>