• Archives

  • Connecting to a database

    By admin | December 18, 2007

    Connecting to a database through php is not a tough task.

    First off all create a new sql database in phpmyadmin and see the privileges section in it for the user/pass by default it is

    Username == “root”

    Password == “”

    In php you need this and your host name it is always localhost


    $host = "localhost"; //Host name
    $username = "root"; // Username
    $pass = ""; //Password
    $dbname = "useless"; //Database Name

    $connect = mysqli_connect ($host,$username,$pass,$dbname);
    if(! $connect)
    echo “unable to connect to the database”;
    echo “Connected to database”;
    The above script will connect you to the database note you must php 5
    because it uses mysqli functions


    Topics: PHP | Comments Off on Connecting to a database

    Related Links: