Change background image
  1. What's up? I see you're viewing as a Guest. How about registering, it only takes like 2 minutes. This will enable you to do more on our forum and stay updated.

How to connect to a database with php

Discussion in 'PC General' started by Nuke547, Jul 11, 2011.

Thread Status:
This thread is more than 180 days old.
  1. Nuke547

    Nuke547 Junior Member Member

    Connecting to a database with php, if fairly simple.

    Code:
    mysql_connect(servername,username,password);
    Thats all there is to it. If your going to use it in multiple pages, just make another file called "connect.php", and at the top of the php file, type:
    Code:
    include("connect.php");
    Thats all there is to it. Then you just make your login form, registration form, or whatever you want.
  2. 3nvisi0n

    3nvisi0n The R3v0lu710n Super-Mod

    One thing I might add is mysql_select_db, often times you will only be connecting to one database(larger sites maybe not) so in connect.php I would include mysql_select_db('databaseName'); since it is something you also only call once and optimally immediatly after connection.
  3. Jok3r

    Jok3r MC-Admin/Summoner Member

    I can see where this may be useful...
    not going to say because im not sure, dont want to cause any shame for myself, why dont you post some of the common uses for this... @Nuke
Thread Status:
This thread is more than 180 days old.

Share This Page