• home
  • forum
  • my
  • kt
  • download
  • Connect to a MySQL Database

    Author: 2009-03-08 09:41:21 From:

    Code:
    <?php
    $username 
    "database_username";
    $password "database_password";
    $database "database_name";
    $hostname "localhost";
    $connect     mysql_connect("$hostname""$username""$password")
                or die(
    "Unable to connect to database!");
                
    mysql_select_db("$database"$conn);
    ?>

    The first variables you see define your MySQL info. The connect variable makes it either connect you the database or let you know it was unable to.

    You can either put this directly int he file you intend to interact with your database or make a new file named sql.php and put all that code in there and include sql.php on the pages you want to use MySQL stuff.

    discuss this topic to forum

    relation tutorial

    No information

    Category

      Ad Management (6)
      Calendars (3)
      Chat Systems (8)
      Content Management (41)
      Cookies and Sessions (12)
      Counters (15)
      Database Related (27)
      Date and Time (13)
      Development (19)
      Discussion Boards (8)
      E Commerce (8)
      Email Systems (13)
      Error Handling (7)
      File Manipulation (24)
      Flash and PHP (6)
      Form Processing (19)
      Guestbooks (12)
      Image Manipulation (21)
      Installing PHP (7)
      Introduction to PHP (23)
      Link Indexing (8)
      Mailing List Management (9)
      Miscellaneous (53)
      Networking (8)
      News Publishing (9)
      OOP (24)
      PEAR (6)
      PHP vs Other Languages (2)
      Polls and Voting (6)
      Postcards (1)
      Randomizing (14)
      Redirection (11)
      Searching (9)
      Security (29)
      Site Navigation (16)
      User Authentication (14)
      WAP and WML (7)
      Web Fetching (8)
      Web Traffic Analysis (15)
      XML and PHP (16)

    New

    Hot