Simplest Way to Connect to a MySql Database
If you are looking for a PHP short code to connect to your MySql database, please check out the following code for PHP/MySql database connectivity. This is simplest way to connect to a MySql database using PHP.
<?php
$link = mysql_connect(‘host-address’, ‘mysql_user’, ‘mysql_password’);
if (!$link) {
die(‘Not connected : ‘ . mysql_error());
}
// assume “database-name” as the current db
$db_selected = mysql_select_db(‘database-name’, $link);
if (!$db_selected) {
die (‘Can\’t use database-name: ‘ . mysql_error());
}
?>
Latest posts by Soumyajit Dutta
- Wordpress Plug-in For Showing Custom Menu Within A Post Or Page - September 19th, 2011
- Add Custom Input Fields In Custom Post Type Using Custom Field Template Plugin - August 10th, 2011
- WordPress Tutorial - June 14th, 2011
- Create Your Own Website For Free With Byethost.Com - April 12th, 2011
- Ideal Process to Organize Your Project - March 14th, 2011
Tags:
