Location: PHPKode > scripts > DNP script > install/dbtest.php
<?PHP
/*
    This file is part of DNP Script, an open source domain portfolio manager.
    Copyright (C) 2011  Robert Picard

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as
    published by the Free Software Foundation, either version 3 of the
    License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

	// We don't want any unsightly PHP error messages coming back to the user
	error_reporting(0);
	
	// Get the database credentials sent to us from the test link
	$h	=	urldecode($_GET['h']);
	$u	=	urldecode($_GET['u']);
	$p	=	urldecode($_GET['p']);
	
	// Make sure they've entered a host name. I could just let the next part take care
	// of this but I can return a more specific error message this way.
	if($h == NULL){
		echo '<span class="message_warning">You need to enter a host name. <a href="#" onClick="testDb()">Try again?</a></span>';
		die;
	}

	// The rest of this code attempts to open a connection to the database with the specified
	// credentials and returns a message on success or failure.
	$con = mysql_connect($h, $u, $p);
	
	if(!$con){
		echo '<span class="message_warning">DNP Script could not connect to the database. <a href="#" onClick="testDb()">Try again?</a></span>';
	}
	else{
		echo '<span class="message_success">DNP Script connected to the database!</span>';
	}
?>
Return current item: DNP script