sql database connectivity

Solutions on MaxInterview for sql database connectivity by the best coders in the world

showing results for - "sql database connectivity"
Marc
15 Sep 2019
1
2<?php
3$db_host = "localhost";
4$db_user = "your database username";
5$db_password = "your database password";
6$db_name = "your database name";
7
8$conn =  mysqli_connect($db_host, $db_user, $db_password, $db_name);
9// mysql_connect($db_host, $db_user, $db_password) or die('error');
10// mysql_select_db('db_name')  or die('db not found');
11// echo 'connected';
12
13if(!$conn->connect_error){
14    die("connection failed ". mysqli_connect_error());          
15}
16    // echo"connected";
17    if(mysqli_query($conn, $db_name)){
18        echo "Database created";
19    }else{
20        echo "error creating database";
21    }
22    mysqli_close($conn);
23
24
25?>