Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2002
    Location
    faisalabad
    Posts
    3

    Post Unanswered: I Have Installed Mysql, But Don't Know How To Connect

    I HAVE INSTALLED MYSQL, BUT DON'T KNOW HOW TO CONNECT

  2. #2
    Join Date
    Dec 2002
    Posts
    17
    Use this in your PHP scripts:

    ----------

    host = Your DB host type. This is usually 'localhost'
    dbusername = The username you use to access your database with.
    dbpassword = The password you use in conjunction with the username to access your database.

    $connection = @mysql_connect("$host", "$dbusername", $dbpassword") or die("Could not connect to the database. Reason:" .mysql_error());

    ----------

    Note: The bold tags are simply there to help you make sense of the code.

    Refer to the $connection VAR later in your script when using queries and other stuff like that. Make sure you use the mysql_select_db(); function to select which database you are using.


    May I suggest you take a peek at www.php.net/manual/ for futher references on connecting to databases.
    Last edited by noodle; 12-28-02 at 20:54.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •