I've been using the following connection string:
@$db = mysql_connect("localhost", "user", "password") or die ($db_die_msg);
mysql_select_db('database');
This works fine, but I keep seeing connection strings around in a format similar to this:
$dsn = "mysql://user:password@localhost/database";
$db = DB::connect($dsn);
if (DB::isError($db)) {
die ($db->getMessage());
}
When I try this though I keep getting an error message - "undefined class name 'db'".
Question 1: what am I doing wrong?
Question 2: is one method better or worse than the other? I like the tidyness of the second option. Is there a good online explanation of the two methodologies?
Thanks!
- Bob