|
dbconnect.php
|
|
|
<?php
|
|
|
$host = 'localhost';
|
|
|
$user = 'root';
|
|
|
$pass = '';
|
|
|
$dbname = 'mydatabase';
|
|
|
|
|
|
if($mycon = @mysqli_connect($host, $user, $pass)){
|
page will coonect to the server
|
|
//echo 'connected to the server';
|
priunts perfectly connected to server
|
|
if(@mysqli_select_db($mycon, $dbname)){
|
connects to data base
|
|
//echo 'connected to the DB';
|
if perfectly connected, it prints, perfectely connected to
database
|
|
} else {
|
|
|
//echo 'DB connection failed';
|
|
|
} }
|
|
|
|
|
|
else {
|
|
|
//echo 'server connection failed';
|
|
|
}
|
|
|
|
|
|
|
|
|
?>
|
|
|
With require and include, we can get the variables used in that
template and results also
|
| @mysqli_connect | |||||
| @mysqli_select_db | |||||
if if else else
|
No comments:
Post a Comment