insert, update functions uses mysql_real_escape_string as default some database with table: mysql> select * from gb; +----+--------+--------+-------+--------+---------+----------------+------------+-----------+-------------+------------------------------------------------------------------+ | id | u_nick | u_from | u_www | u_mail | u_where | u_entry | u_date | u_user_ip | u_user_host | u_user_agent | +----+--------+--------+-------+--------+---------+----------------+------------+-----------+-------------+------------------------------------------------------------------+ | 74 | | | | | | ZONK ZONK ZONK | 1264348058 | 10.0.1.10 | 10.0.1.10 | Opera/9.80 (X11; Linux i686; U; pl) Presto/2.2.15 Version/10.10 | | 83 | a | b | c | d | eee | fff | 1264874583 | 10.0.1.10 | 10.0.1.10 | Mozilla/5.0 (compatible; Konqueror/4.3; Linux) KHTML/4.3.4 (like | +----+--------+--------+-------+--------+---------+----------------+------------+-----------+-------------+------------------------------------------------------------------+ 2 rows in set (0.00 sec) --- // define a new object for db instance - make array with host data or supply it directly to the object: $prd = array('user' => 'tomekk', 'pass' => 'mypass', 'host' => 'myhost', 'db' => 'mydb', 'force_enc' => 'utf8'); <- force_enc is optional - call new obj: $db = new dbase($prd); If you need more connections, just make more array with hosts and call new objects. Ok, some examples... //regular query $result = $db->query("SELECT `id`, `u_entry` FROM gb"); while ($row = mysql_fetch_row($result)) { echo $row[0] . $row[1] . "\n"; } 74 ZONK ZONK ZONK 83 fff --- //use for single output $max_id = $db->fetch("SELECT MAX(id) FROM gb"); echo $max_id; 83 --- //simple insert $data['u_nick'] = "newnick"; $data['u_from'] = "space"; $db->insert("gb", $data); mysql> select * from gb order by id; +----+---------+--------+-------+--------+---------+----------------+------------+-----------+-------------+------------------------------------------------------------------+ | id | u_nick | u_from | u_www | u_mail | u_where | u_entry | u_date | u_user_ip | u_user_host | u_user_agent | +----+---------+--------+-------+--------+---------+----------------+------------+-----------+-------------+------------------------------------------------------------------+ | 74 | | | | | | ZONK ZONK ZONK | 1264348058 | 10.0.1.10 | 10.0.1.10 | Opera/9.80 (X11; Linux i686; U; pl) Presto/2.2.15 Version/10.10 | | 83 | a | b | c | d | eee | fff | 1264874583 | 10.0.1.10 | 10.0.1.10 | Mozilla/5.0 (compatible; Konqueror/4.3; Linux) KHTML/4.3.4 (like | | 89 | newnick | space | | | | | | | | | +----+---------+--------+-------+--------+---------+----------------+------------+-----------+-------------+------------------------------------------------------------------+ 3 rows in set (0.00 sec) --- //simple update $data['u_www'] = "some www"; $data['u_mail'] = "some mail"; $db->update("gb", $data, "id=89"); mysql> select * from gb order by id; +----+---------+--------+----------+-----------+---------+----------------+------------+-----------+-------------+------------------------------------------------------------------+ | id | u_nick | u_from | u_www | u_mail | u_where | u_entry | u_date | u_user_ip | u_user_host | u_user_agent | +----+---------+--------+----------+-----------+---------+----------------+------------+-----------+-------------+------------------------------------------------------------------+ | 74 | | | | | | ZONK ZONK ZONK | 1264348058 | 10.0.1.10 | 10.0.1.10 | Opera/9.80 (X11; Linux i686; U; pl) Presto/2.2.15 Version/10.10 | | 83 | a | b | c | d | eee | fff | 1264874583 | 10.0.1.10 | 10.0.1.10 | Mozilla/5.0 (compatible; Konqueror/4.3; Linux) KHTML/4.3.4 (like | | 89 | newnick | space | some www | some mail | | | | | | | +----+---------+--------+----------+-----------+---------+----------------+------------+-----------+-------------+------------------------------------------------------------------+ 3 rows in set (0.00 sec) --- //real escape $some_unescaped_string = "'`'\""; echo $some_unescaped_string . "\n"; echo $db->resc($some_unescaped_string) . "\n"; '`'" \'`\'\" --- //affected rows $data['u_where'] = "from space"; $db->update("gb", $data, "id > 80"); echo $db->affected_rows(); 2 --- //num rows $result = $db->query("SELECT * FROM gb"); echo $db->num_rows(); 3 --- //num fields $result = $db->query("SELECT id, u_nick, u_www, u_where FROM gb"); echo $db->num_fields(); 4 --- //queries counter $result = $db->query("SELECT id, u_nick, u_www, u_where FROM gb"); $result2 = $db->query("SELECT u_date FROM gb"); echo $db->queries_counter(); 3 (+1 for "SET NAMES") --- //last AI ID insert id $data['u_nick'] = "nick2"; $data['u_from'] = "from2"; $db->insert("gb", $data); echo $db->last_ai_id(); 90 mysql> SELECT MAX(id) FROM gb; +---------+ | MAX(id) | +---------+ | 90 | +---------+ 1 row in set (0.00 sec) --- //result seek back $db->seek_back(); Use when you want use the same 'result variable' two or more times (seek_back moves internal pointer to the beginning, check mysql_data_seek() at php.net) --- //close $db->close(); But as you probably know, connection is automatically closed.