Today i will introduce for you a how to connect database mysql in php, this is problem very meet in code php.
Write function connect to mysql in php below:
Write function connect to mysql in php below:
<?phpuse php in HTML
$server ='localhost';
$user ='root';
$pass ='';
$conn = mysqli_connect($server,$user,$pass);
if(!$conn){
die("don't connect :" .mysql_error());
}
echo "Connected successfully";
mysqli_close($conn);
?>
<html>
<head>
<title>How to connect to mysql</title>
</head>
<body>
<?php
$server ='localhost';
$user ='root';
$pass ='';
$conn = mysqli_connect($server,$user,$pass);
if(!$conn){
die("don't connect :" .mysql_error());
}
echo "Connected successfully";
mysqli_close($conn);
?>
</body>
</html>
No comments:
Post a Comment