On Dec 10, 2007 3:16 AM, Dave M G <martin@xxxxxxxxxxxxx> wrote: > Which assumption should I be proceeding with? Rather than assume (because we all know what happens then), why not build for both scenarios? Here's an example of one way.... <? // inc/include_files.php # # Includes all files necessary in one file. # include_once('inc/config.php'); include_once('inc/db.php'); include_once('func/db.php'); ?> <? // inc/db.php # # Database connection information. # // Establish the connection with the primary database.... if(function_exists('mysqli_connect')) { $db_conn = mysqli_connect($_DB[host],$_DB[user],$_DB[pass]) or die ('I couldn\'t connect to the database. Know why? Because MySQL is complaining about something. Does this make sense to you...? :<BR />'.mysql_error()."\n"); } else { $db_conn = mysql_connect($_DB[host],$_DB[user],$_DB[pass]) or die ('I couldn\'t connect to the database. Know why? Because MySQL is complaining about something. Does this make sense to you...? :<BR />'.mysql_error()."\n"); } ?> <? // func/db.php # # Customized database functions. # function db_error($function) { // This is what we'll use to process and output (or otherwise handle) errors. $err = "MySQL error reached when calling function ".$function."(). MySQL said:<BR />\n"; $err .= "<FONT COLOR=#FF0000>"; if(function_exists('mysqli_error')) { $err .= mysqli_error(); } else { $err .= mysql_error(); } $err .= "</FONT><BR />\n"; $err .= "<BR />\n"; return $err; } function db_query($sql) { // Simply return the connection resource ID require('inc/config.php'); require('inc/db.php'); // Select the site database.... if(function_exists('mysqli_query')) { $db_select = mysqli_select_db($_DB[name],$db_conn); } else { $db_select = mysql_select_db($_DB[name],$db_conn); } return $r; } ?> <? // index.php # # The primary file. # $sql = "SELECT * FROM table_name"; // Note that you use the custom function `db_query()`, // not `mysql_query()` or `mysqli_query()`. $result = db_query($sql); while($row = mysql_fetch_array($result)) { // Do the rest of your stuff here. } ?> -- Daniel P. Brown [Phone Numbers Go Here!] [They're Hidden From View!] If at first you don't succeed, stick to what you know best so that you can make enough money to pay someone else to do it for you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php