Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I connect to Mysql?

Retrieving Data

How do I connect to Mysql?

by  devnull22  Posted    (Edited  )
<?php
// define vars
$sqlhost = "localhost";
$db_user = "sql_user_name";
$db_password = "sql_user_name_password";
<font color=green>
// now make the connection.
// note: $dbh is the database handle, you can make
// multiple connections if you want or give it
// a differenet name.[/tt]
$dbh = mysql_connect($sqlhost,$db_user,$db_password);
mysql_select_db($database_name,$dbh);
$err = mysql_error();
if ($err){
echo "Error in database : $err";
exit;
};
?>


Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top