PHP | mysqli_dump_debug_info() Function

PHP mysqli_dump_debug_info() Function


Hello dear readers! welcome back to another edition of our tutorial on PHP. In this tutorial guide, we are going to be discussing about the PHP mysqli_dump_debug_info() Function.

The built-in PHP mysqli_dump_debug_info() function accepts an object representing a connection to the MYSQL server and, then dumps the debugging information into the log.

Syntax

Following below is the syntax to use this function -

mysqli_dump_debug_info($con);


Parameter Details

Sr.NoParameter & Description
1

con(Mandatory)

This is an object representing a connection to MySQL Server.


Return Value

This built-in PHP functions returns TRUE on success and FALSE on failure.

PHP Version

This built-in function was introduced in PHP version 5 and works in all the later versions.

Example1

Following example demonstrates the usage of the PHP mysqli_dump_debug_info() function (in procedural style) -

<?php
   //Creating a connection
   $con = mysqli_connect("localhost", "root", "password", "mydb");
   $res = mysqli_dump_debug_info($con);

   if($res){
      print("Debugging is successful");
   }else{
      print("Failed to debug");
   }
?>

Output

When the above code is executed, it will produce the following result -

Debugging is successful

Example2

Try the following example below -

<?php
   $servername = "localhost";
   $username = "root";
   $password = "password";
   $dbname = "mydb";
   $conn = new mysqli($servername, $username, $password, $dbname);

   if ($conn->connect_error) {
      die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
   } 
   echo 'Success... ' . mysqli_get_host_info($conn)."\n";
   mysqli_dump_debug_info($conn);
   mysqli_autocommit($conn,FALSE);
   mysqli_query($conn,"INSERT INTO tutorials_auto (id,name) VALUES (10,'sai')");
   mysqli_commit($conn);
   
   mysqli_close($conn);
?>

Output

When the above code is executed, it will produce the following result -

Success... localhost via TCP/IP


Alright guys! This is where we are rounding up for this tutorial post. In our next tutorial, we will discuss about the mysqli_error() Function in PHP.

Do feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Do follow us on our various social media handles available and also subscribe to our newsletter to get our tutorial posts delivered directly to your emails.

Thanks for reading and bye for now.