Jumat, 21 September 2018

Test Database Connectivity Using Php Script

1Many times, Influenza A virus subtype H5N1 organization administrator needs to seek out a connexion betwixt APP server as well as DB server. It tin mail away live required when around developer reporting upshot piece they connect to the Database server from their application. 

It is a really helpful PHP script that gives us really useful output as well as tin mail away assist inwards the troubleshooting. In this my blog, I'm going to portion a PHP script amongst around example.
Prerequisites- 

  • Database Server's HostName
  • A Database Name
  • DB user / Password
  • Another System installed PHP
Step 1- Create a PHP Script
To practise your PHP script inwards your lastly session practise a novel file using vi editors. 

$ vi db-test.php

Now, re-create the script below as well as glue inwards your file.

<?php $servername = "MySQL_Host"; $username = "MySQL_UserName"; $password = "MySQL_Password";  // Create connexion $conn = mysqli_connect($servername, $username, $password);  // Check connexion if (!$conn) {     die("Connection failed: " . mysqli_connect_error()); } echo "Connected successfully"; ?>  
$ php db-test.php  Connected successfully Establish to Database Server Name: '192.168.10.11'

Replace all the highlighted text amongst your's details.
Step 2 - Run PHP Script to seek out Database connectivity. 
There is 2 agency to run your PHP script. 
1- One yous tin mail away run from the lastly followed yesteryear this command. 

$ php db-test.php

If your connexion to DB server is successful, yous volition larn output similar this. 

2- You tin mail away house db-test.php file inwards your Apache document root folder as well as telephone telephone this script using the spider web browser. 
If your remote server has access to the DB server therefore yous Browser output volition live similar this.

You bring successfully tested Database connectivity using PHP script. 


Sumber https://linuxhowtoguide.blogspot.com/

Tidak ada komentar:

Posting Komentar