Admin-Ahead Community

Linux => General Linux => Topic started by: joseletk on March 24, 2018, 05:41:50 pm

Title: How do I use PHP to access my MySQL database?
Post by: joseletk 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
---------------------------------------------------------------------------------------------------------------------------------