Offers/News
Live Support
LiveZilla Live Help
IP Address
  • IP-Adresse
Translator

Posts Tagged ‘connect’

How do I connect to my MySQL database?

A simple php script to open a connection to a database

<?php
$dbhost = ‘localhost’;
$dbuser = ‘db username’;
$dbpass = ‘db password’;

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die (‘Error connecting to mysql’);

$dbname = ‘db name’;
mysql_select_db($dbname);
?>

Save this as <something>.php and then whenever you want to access the database, just add

include ‘<something>.php’

to the top of a php script and the database can be queried using standard sql commands.

Search WoWHost
Customer Info/Advice
  • Customer How To (26)
  • Legal (5)
  • SEO Hints & Tips (4)
Copyright and TM 2007-2010 WoW-4.co.uk