Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php mysqli connection check

/* Procedural style */
<?php
 
$conn = mysqli_connect("localhost", "user", "password", "database");

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s
", mysqli_connect_error());
    exit();
}

/* check if server is alive */
if (mysqli_ping($conn)) {
    printf ("Our connection is ok!
");
} else {
    printf ("Error: %s
", mysqli_error($conn));
}

/* close connection */
mysqli_close($conn);
?>
Comment

PREVIOUS NEXT
Code Example
Php :: PHP extension simplexml 
Php :: what php can do 
Php :: php max_execution_time 
Php :: get database name laravel 
Php :: get featured image url in wordpress 
Php :: php force array keys to lowercase 
Php :: php pdo get database name 
Php :: laravel find or create new 
Php :: laravel get last record 
Php :: laravel convert timestamp to date 
Php :: show php erros 
Php :: how to get last array element in php 
Php :: flutter boxdecoration add border 
Php :: double in migration laravel 
Php :: php mysql connect 
Php :: php check if session is running 
Php :: php convert array to json object 
Php :: php array get first x elements 
Php :: switch between php version ubuntu nginx 
Php :: php ping time 
Php :: replace _ with space php 
Php :: laravel eloquent increment 
Php :: yii2 redirect back 
Php :: select in php mysql 
Php :: ext-dom php 7.2 
Php :: wordpress echo the page title 
Php :: switch in laravel 
Php :: laravel php short if 
Php :: mysql timestamp format php 
Php :: add to url anchor tag laravel with variable 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =