HOME | PHP Tutorial | CSS
facebook icon
AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP
PHP Tutorial

PHP forms
HTML Tutorial

CSS Tutorial

PHP mysqli_connect() Function


PHP provides mysqli_connect() function to open a SQL database connection. This function takes five parameters and returns a MySQLi link identifier on success or FALSE on failure.

Parameters: 1 server, 2 user, 3 password, 4 new_link, 5 client_flags.

Connect to MySQL server useing mysqli_connect() Function - how to create - example


Here is a simple example to connect to MySQL server

Example 1: mysqli_connect() Function
<?php
$link = mysqli_connect("localhost", "myuser", "mypassword", "mydb");

if (!$link) {
    echo "Error: Unable to connect to MySQL." . PHP_EOL;
    exit;
}

echo "Success: A proper connection to MySQL was made!" . PHP_EOL;
echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;

mysqli_close($link);
?>

You can disconnect from MySQLi database anytime using another PHP function mysqli_close(). This function takes a single parameter, which is a connection returned by mysqli_connect() function.


php mysqli connect function PHP mysqli_connect () Function - sql tutorial

2086. SQL Tutorial | Database Tutorial | Examples
SQL Tutorial for SQL Server. For beginners with examples.
https://www.dofactory.com/sql/tutorial

2573. SQL HAVING - SQL Tutorial

http://www.sql-tutorial.net/SQL-HAVING.asp

2566. SQL BETWEEN - SQL Tutorial

http://www.sql-tutorial.net/SQL-BETWEEN.asp

2578. SQL LIKE - SQL Tutorial

http://www.sql-tutorial.net/SQL-LIKE.asp

3295. SQL mysql order by columns, by date, by asc, by desc, random with PHP, sql tutorial
SQL mysql order by columns, by date, by asc, by desc, random with PHP sql tutorial
https://www.agernic.com/sql-tutorial/sqlL-mysql-order-by-columns-asc--desc--random-with-php.html

2585. SQL Server - SQL Tutorial

http://www.sql-tutorial.net/sql-server.asp

Your add here
PHP htmlspecialchars() function

PHP lcfirst() function

PHP ucfirst() function

PHP isset() Function

PHP strrchr() Function

PHP html_entity_decode() function

PHP ltrim() function

PHP strstr() function

PHP implode() function

PHP htmlentities() function

PHP strip_tags() function

PHP define() function

PHP str_split() function

PHP rtrim() function

PHP md5() function

PHP strtoupper() function

HTML Text Align
HTML Text Color
HTML Image Border
Easy Learning with "Show PHP", example of a simple php script.
CSS Text Decoration
CSS text-align