Web Hosting
e-commerce hosting

Coldfusion Hostingecommerce hosting shopping cart solution

shopping cart hosting   
 
 


  Connecting to an MySQL Database Using PHP

This example describes using PHP to connect to a MySQL Database on a Windows hosting account.

<?php
//Sample Database Connection Syntax for PHP and MySQL.

//Connect To Database
$hostname="mysql.secureserver.net";
$username="your_dbusername";
$password="your_dbpassword";
$dbname="your_dbusername";
$usertable="your_tablename";
$yourfield = "your_field";
mysql_connect($hostname,$username, $password) OR DIE (" ");
mysql_select_db($dbname);

# Check If Record Exists

$query = "SELECT * FROM $usertable";

$result = mysql_query($query);

if($result)
{
while($row = mysql_fetch_array($result))
{
$name = $row["$yourfield"];
echo "Name: ".$name."
";
}
}
?>

 

     

ecommerce hostingcold fusion hosting

All use of this Web site is subject to the Terms of Service.
©1997-2010 Infinities eCommerce Web Hosting and Shopping Cart Solution.


PHP Hosting  | MySQL Hosting | Shopping Cart Demo | ColdFusion Hosting | Ecommerce Hosting

Live Chat by Comm100