PHP MySQL: Making connection to DB non OOP procecural style

The earlier example was done using object oriented style of coding.

We can use the procedural method as shown below.

In Non OOP procedural method, we use mysql_connect.

$link = mysqli_connect("localhost", "root", "", "allartist");

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
} else {
    printf("Connection to DB successful");

It is recommended to use the newer OOP way of coding.

Series Navigation<< PHP MySQL: Making a connection to MySQL OOP Style
PHP MySQL: Create Database >>