how can connect database to SQL?

<?php
// Create connection
$con=mysql_connect("localhost","root","");

// Check connection
if (mysql_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysql_connect_error();
  }
?>   

Before we can really answer that you are going to have to tell us which database you are trying to connect to (MySQL, MS SQL Server, Access, Oracle, etc.) and what you are trying to connect from (VB script, web page, php, c, etc.)

<?php
#Database properties
$DB_HOST="localhost";
$DB_NAME="db_name";
$DB_USER="root";
$DB_PASSWORD="";
$default_dbname='db_name'; 
// instantiate db connection
$dbconn = mysql_connect($DB_HOST,$DB_USER,$DB_PASSWORD) or die ("Could not connect to database");
mysql_select_db($DB_NAME) or die ("could not open database");

?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.