For a mySQL lookup, I have always used:
mysql_select_db(\'my_db\', mysql_connect( \'localhost\', \'my_username\', \'password\'))
But, when I had programming work done for me, they used:
define(\"DB_HOST\", \"localhost\");
define(\"DB_USER\", \"my_username\");
define(\"DB_PASS\", \"password\");
define(\"DB_NAME\", \"my_db\");
$DBH = \"\";
if( !$DBH = mysql_connect(DB_HOST, DB_USER, DB_PASS) ) {
echo \"<h2>Cannot connect to database server!</h2>\";
echo \"Mysql error: \", mysql_error();
die;
}
if( !mysql_select_db(DB_NAME, $DBH) ) {
echo \"<h2>Cannot access database!</h2>\";
echo \"Mysql error: \", mysql_error();
die;
}
?>
What on EARTH did they do all that for?
Does php connect to mySQL FASTER than my way? Or is it actually a bit slower. What kind of programming did they use, since it looks different than regular php???
Thank you!