sql database connectivity 1

sql database connectivity

connect_error){
    die("connection failed ". mysqli_connect_error());          
}
    // echo"connected";
    if(mysqli_query($conn, $db_name)){
        echo "Database created";
    }else{
        echo "error creating database";
    }
    mysqli_close($conn);


?>

Here is what the above code is Doing:
1. We are creating a connection to the database.
2. We are checking if the connection is successful or not.
3. If the connection is successful, we are creating a database.
4. If the connection is not successful, we are displaying an error message.
5. We are closing the connection.

Now, let’s create a table in the database.

Similar Posts