Toggle navigation
Home
Latest pastes
FAQ
Random
Register
Login
Connect to Database - PHP Sequential Approach
SUBMITTED BY:
YouKnowNothing
DATE:
Jan. 11, 2016, 12:27 p.m.
FORMAT:
PHP
SIZE:
508 Bytes
Raw
Download
Tweet
HITS:
1399
Go to comments
Report
<?php
//This script connects to the database
//Server information
$server
=
"servername"
;
//e.g. localhost:8889
$user
=
"username"
;
$pass
=
"password"
;
//Initiate connection
$conn
=
mysqli_connect
(
$server
,
$user
,
$pass
);
if
(
!
$conn
){
die
(
"Connection to server failed: "
.
mysqli_connect_error
());
}
echo
"Connected to server"
;
//Connect to database
$db
=
mysql_select_db
(
$conn
,
"database name"
);
if
(
!
$db
){
die
(
"Database failed: "
.
mysqli_connect_error
());
}
echo
"Connected to DB"
;
?>
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus