Monday 19 February 2018

PHP MySQL Connect

mysqli_connect() function is used to connect php code with MySQL database. It returns resource if connection is established otherwise null.
Syntax:
resource mysqli_connect(server,username,password)
mysqli_close()
mysqli_close() function is used to close the connection.
It is used to disconnect php code with MySQL database. It returns true if connection is closed otherwise false.
  Syntax:
  bool  mysqli_close( resource  $resource_link)

Example:
<?php 
$servername= 'localhost’; 
$username = 'root'; 
$password = ''; 
$con = mysqli_connect($servername, $username, $password); 
if(! $con ) 
{ 
  die('Could not connect: ' . mysqli_error()); 
} 
echo 'Connected successfully'; 
mysqli_close($con); 
?> 
Output:
Connected successfully

No comments:

Post a Comment

apply function in R

1) apply function: It takes 3 arguments matrix,margin and function.. Example: m<-matrix(c(1,2,3,4),nrow=2,ncol=2) m #1 indicates it is ap...