+91 88 00 563434sales@webhostingpeople.net Blogopen-book Knowledge Base
Table of Contents
Print

Establishing a Connection to a MySQL Database with PHP on Linux Hosting

There’s following a pattern code for connecting to a MySQL database utilizing PHP.

//Pattern Database Connection Syntax for PHP and MySQL.

//Join To Database
$hostname=”mysql.secureserver.web”;
$username=”your_dbusername”;
$password=”your_dbpassword”;
$dbname=”your_dbusername”;
$usertable=”your_tablename”;
$yourfield = “your_field”;
$connection = mysql_connect($hostname, $username, $password);
mysql_select_db($dbname, $connection);

# Examine If Report Exists

$question = “SELECT * FROM $usertable”;

$outcome = mysql_query($question);

if($outcome)
{
whereas($row = mysql_fetch_array($outcome))
{
$title = $row[“$yourfield”];
echo “Identify: “.$title.”
“;
}
}
?>

Leave a Comment

Categories
WebHostingPeople
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.