Database Connection Process:
Here I Explained the database connectivity:-Server name kept here "localhost", Username "root", Password kept " "(blank), and keep the name of database as you are using for database name
For example I used the name of the database is "exam", and copy this code and you can use it for database connectivity for your website:
<?php
define('SERVER','localhost');
define('USERNAME','root');
define('PASSWORD','');
define('DATABASE','exam');
if(@$conn=mysql_connect(SERVER,USERNAME,PASSWORD))
{
mysql_select_db(DATABASE,$conn);
}
else
{
echo"<script>alert('opps!something went wrong with this connection!')</script>";
echo "<script>document.location.href='http://www.google.com'</script>";
}
?>
Comments