Results 1 to 3 of 3
  1. #1

    Default How to Connect to Your Database in PHP MySQL

    A proper connection with dabase is necessary in PHP MySQL, otherwise any queries or scripts will not be able to read or write the data in database.

    Setting database name, Username and password at starting of the script code is necessary to build a connection with database. Later on you can change any of these if you want.

    Replace "your_username", "your_password" and "your_database" with your MySQL username, password and database name respectively, this will be used by your script.

    Now you can use following 'mysql_connect' PHP function to connect your PHP script with your database.


    Above function instructs PHP to connect with MySQL database server at 'localhost' which normally runs on the same physical server on which you script runs.

  2. #2
    Join Date
    May 2013


    Isn't there any security risk in keeping the password stored in the database file?

  3. #3



    No, there is no security risk as the PHP source code is processed by the server before it's being sent to the browser. So the normal internet user will not be able to identify the script's code in the page's source.

Tags for this Thread

Posting Permissions

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