Jump to content

Proper MySQLI Database Connection...


rootKID

Recommended Posts

Hello, quick question... i have been told by a friend if i use the "ping" function in php, people would be able to make a "POD - Ping Of Death (DOS/DDOS)" to the server?

 

This is my php function:

    function main_database_connection ()	{		global $DB;		$db_verify = mysqli_connect( $DB['host'], $DB['user'], $DB['password'], $DB['database'] );		        // Database Alive? (Check by ping PHP function!)		if ( mysqli_ping( $db_verify ) )		{			$mysqli = new mysqli (				$DB['host'],				$DB['user'],				$DB['password'],				$DB['database']			);						// Error check			if ( mysqli_connect_errno() )			{				echo "<b><u>"."An unexpected error happened when we tried to connect to the (MAIN) database server!"."</u></b>";				echo "<br />";				echo mysqli_connect_error();				exit();			}						// change database characters (collation)			$mysqli -> set_charset( $DB['charset'] );						// (query_connection) MAKER			// ----------------------------------------------------------------						//$GLOBALS["dbconn"] = $mysqli;            $GLOBALS["{$DB['globals']}"] = $mysqli;						// ----------------------------------------------------------------						////////////////////////////////////////////////////////////			// Loaders / Updaters			////////////////////////////////////////////////////////////			// Connection Type:			// MySQLI = Secured MySQLI Database Connection			////////////////////////////////////////////////////////////						// $connection = $mysqli; // Not used yet						// LOADERS GO FROM HERE AND BELOW!			// Example:			// curuser_loader();			// Just add the function like that as you would usually and you are good to go...		}		else		{			die("<br /><br />Main Database server not alive for some reason, come back later! Or check the host-service!");		}	} // End "main_database_connection" Function

Can anyone confirm with me if this is correct etc? I just wonna make sure it is connecting the proper way x)

 

Thanks! :)

Link to comment
Share on other sites

Putting any PHP code into any file has zero to do with whether or not a server is vulnerable to a ping of death attack. Your server either is or is not vulnerable to that attack regardless of any files on the system. Older servers may be vulnerable. Newer ones should not be. It has nothing to do with PHP.That code is kind of pointless though. You connect once, then ping the server, and if you're connected then you connect again. You only need to connect once, you can check then whether it succeeded.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...