Divi WordPress Theme

Topic: PHP MySQL Example - PHP MySQL sample connection Tutorial  (Read 5197 times)

Offline Kevin

  • Junior Guru
  • **
  • Posts: 72
  • iTrader: +4/-0
    • View Profile
PHP MySQL Example - PHP MySQL sample connection Tutorial
« on: August 19, 2008, 01:02:41 AM »
If you are facing trouble to connect to your MySQL database you can use the following code to check the database connection:
Code: [Select]
<?php
$dbhost 
'localhost';   // Your MySQL server host
$dbuser 'dbuser';         // MySQL database user
$dbpass 'password'// Password for MySQL database User

$conn mysql_connect($dbhost$dbuser$dbpass) or 
die (
'Error connecting to mysql');
$dbname 'database_name';
mysql_select_db($dbname);
?>

Regards,

Kevin
VPS Hosting - AccuWebHosting

Offline wilsondavid

  • Newbie
  • *
  • Posts: 5
  • iTrader: +0/-0
    • View Profile
Re: PHP MySQL Example - PHP MySQL sample connection Tutorial
« Reply #1 on: December 22, 2011, 05:52:05 PM »
PHP - MYSQL connection :

<?

$link = mysql_connect(" localhost "," root ","");

mysql_select_db("sample",$link);

$result=mysql_query(" SELECT * from employee;");

?>
Shopify Divi WordPress Theme
Tags: