$db = mysql_connect$db_host, $db_user, $db_pass) or die ("Cannot connect to database"); mysql_select_db("$db_name", $db) or die ("Cannot select database"); $result = mysql_query($query ,$db) or die ("Query not executed");
and all the outputting code... grace michiel "Cf High" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hey all. > > I'm currently using the following db connection function, but I'm not sure > if it's as efficient as it could be. > > function dbConnect($SQL) { > > global $result; > > // Connect to DB > if (!$link = @mysql_connect($db_host, $db_user, $db_pass)) { > $result = 0; > echo mysql_errno() . ": " . mysql_error() . "\n"; > } > else > > // Select DB > if ([EMAIL PROTECTED]($db_name, $link)) { > $result = 0; > echo mysql_errno() . ": " . mysql_error() . "\n"; > } > else { > // Execute query > if (!$result = @mysql_query($SQL, $link)) { > $result = 0; > echo mysql_errno() . ": " . mysql_error() . "\n"; > } > } > } > return $result; > } > > ******* Is there a faster way to establish a connection & run a query, or am > I wasting my time over nothing? ********* > > --Noah > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php