Change language

PHP Mysqli_ping () function

This function can be used in both object-oriented and procedural styles, as described below:
  • Object-oriented : Syntax:
    ping(); 
    Parameters:This function takes no parameters, it is used with a connection instance. Return Value : This function returns True on success and False on failure.The following program illustrates the ping() function in an object-oriented style: $servername = " localhost " ; $username = "username" ; $password = "password" ;  
    // Create a connection $conn = new mysqli ( $servername , $username , $password );  
    // Check your connection if ( $conn -> connect_error) { die ( "Connection to the server failed:" . $conn -> connect_error); }  
    / * check if the server is alive * / if ( $conn -> ping()) { printf ( " Successful Coonection! " ); } else { printf ( "Error:% s" , $conn -> error); }  
    / * close connection * / $conn -> close ( ); ?>
  • Procedural style : Syntax:
    mysqli_ping($conn);
    Parameters:This function takes one parameter, $conn, which represents the connection.Return Value : This function returns True on success and False on failure.The following program illustrates mysqli_ping() in a procedural style: $ $servername = " localhost " ; $username = "username" ; $password = "password" ;  
    // Create a connection $conn = mysqli_connect ( $servername , $username , $password );  
    // Test the connection if (! $conn ) { die ( "Connection to the server failed:" . mysqli_connect_error()); }  
    / * check if the server is alive * / if (mysqli_ping ( $conn )) { printf ( "Successful Coonection!" ); } else { printf ( "Error:% s" , mysqli_error ( $conn )); }  
    / * close connection * / mysqli_close ( $conn ); ?>
Link: http://php.net/manual/en/mysqli.ping.php

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

Common xlabel/ylabel for matplotlib subplots

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

12 answers

NUMPYNUMPY

Flake8: Ignore specific warning for entire file

12 answers

NUMPYNUMPY

glob exclude pattern

12 answers

NUMPYNUMPY

How to avoid HTTP error 429 (Too Many Requests) python

12 answers

NUMPYNUMPY

Python CSV error: line contains NULL byte

12 answers

NUMPYNUMPY

csv.Error: iterator should return strings, not bytes

12 answers


Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

sin

How to specify multiple return types using type-hints

exp

Printing words vertically in Python

exp

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

cos

Python add suffix / add prefix to strings in a list

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically