PHP with MySQL-Create mysql connection in php


To connect php with mysql, we need a code to connect.
follow the tutorial below:

  1. create a file "connect.php"
  2. edit script:
  3. <?php
    $host="server";
    $user = "username";
    $pass = "password";
    $dbname = "dbname";
    
    $conn = mysql_connect ($host, $user, $pass);
    if ($conn) {
    $conect = mysql_select_db ($dbname);
    if (!$conect) {
    die ("can't open database!");
    }
    } else {
    die ("Can't connect to server");
    }
    ?>
  4. save and run.
  5. success.


thank you for this blog visit home

kitprogrammer

Comments

Popular posts from this blog

Menambah dan Mengurangi Datetime di SQL SERVER / MYSQL | DATEADD | DATEDIFF

Create Calculator With Visual Studio 2012 | VB.Net Calculator