* the comments in the db.class.php file to get additional information about * any specific function. */ require_once 'db.class.php'; $db = new db_class(); // Open up the database connection. You can either setup your database login // information in the db.class.php file or you can overide the defaults here. // If you setup the default values, you just have to call $db->connect() without // any parameters-- which is much easier. if (!$db->connect('localhost', 'user', 'password', 'database_name', true)) { $db->print_last_error(false); } // Create the table (if it doesn't exist) by executing the external sql // file with the create table SQL statement. echo "Executing SQL commands in external file test_data.sql...<br>"; if (!$db->execute_file('test_data.sql')) { $db->print_last_error(false); } $db->print_last_query(); // This I find very handy. You can build an array as you are working through, // for example, POST variables and validating the data or formatting the data // etc. By defaul, the class will add slashes (addslashes()) to all string data // being input using this function. you can override that by doing: // $db->auto_slashes = false; // You cannot perform any MySQL functions when using insert_array() as the the // function will be enclosed in quotes and not executed. If you have some fancy // MySQL functions you'll want to use the insert_sql() function in which you // provide all the sql. // Also, it's worth pointing out that if the table in which data is being inserted // has an auto_increment value (as this one does), then the function will return // that value which is generated.