Labels

Friday, January 25, 2013

PHP MySql Connect Code

You Can create a .php file with name db_connect.php and follow this code.
<?php
    $con = mysql_connect("localhost","root","");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
   
    $db_selected = mysql_select_db("twee_home",$con);
?>


NOW you can connect your index.php page with db_connect.php 
code below 

top on the page :
<?php
    require_once('db_connect.php');
    session_start();
   
    $
today = gmdate('D d-m-Y H:i:s', strtotime('+6 hours'));  // server today's date, time,
?>


Changes :
"localhost", "root","" = hostname, username, password // IF your mysql password set already

twee_home = database name ,