Pages

Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts

Monday, 1 May 2017

MySQLi Database creation

<?php
$host='localhost';
$user='root';
$pass='';
$conn=mysqli_connect($host,$uAser,$pass);
if(!$conn)
{
    die('Could not connect : '.mysqli_connect_error());
}
echo "Connect successfully</br>";

$sql = 'CREATE  DATABASE mydb';
if(mysqli_query($conn,$sql))
{
    echo "Database mydb created successfull";
}else{
    echo "Sorry, database creation failed ".mysqli_error($conn);
}
mysqli_close($conn);
?>

MySQLi connection (localhost)

<?php  
$host = 'localhost';  
$user = 'root';  
$pass = '';  
$conn = mysqli_connect($host, $user, $pass);  
if(! $conn )  
{  
  die('Could not connect: ' . mysqli_error());  
}  
echo 'Connected successfully';  
mysqli_close($conn);  
?>  

Code Review

 SOLID Principles S – Single Responsibility Principle There should never be more than one reason for a class to change. O – Open-Closed Prin...