Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: How do I use PHP to access my MySQL database?  (Read 1121 times)

0 Members and 1 Guest are viewing this topic.

joseletk

  • Guest
How do I use PHP to access my MySQL database?
« on: March 24, 2018, 05:41:50 pm »
In order to access your MySQL database with the PHP, please follow these steps:

1. Log into your Linux web server via Secure Shell.

2. Type the following connection string to connect to your database:

Code: [Select]
<?php
$link 
mysql_connect('host''username''password') or die('Could not connect: ' mysql_error());
mysql_select_db('database') or die('Could not select database');
?>
---------------------------------------------------------------------------------------------------------------------------------
-> host: enter the MySQL server that you are assigned to, for example, -> mysql4.safesecureweb.com
-> username: enter the username provided for your database
-> password: enter the password provided for your database
-> database: enter the name of the MySQL database
---------------------------------------------------------------------------------------------------------------------------------
« Last Edit: March 24, 2018, 05:43:43 pm by joseletk »