Try It Out Transaction Script Some of these (Web host forum)

Try It Out Transaction Script Some of these files are a bit long. Don t let that scare you. Most of the code consists of SQL statements, and they are explained clearly for you in the How It Works section that follows. Remember that this code can also be downloaded from the Web site (www.wrox.com). 1. Let s start with a transaction script. This code is the longest, but that s because it contains a lot of SQL statements. It s not as bad as it looks. But if you want to download this code from the Web site, go ahead, and be guilt-free. Consider it our gift to you. If you are typing it, you know the drill. After entering it, save this one as char_transact.php: $value) { $$key = $value; } $conn = mysql_connect(SQL_HOST, SQL_USER, SQL_PASS) or die( Could not connect to MySQL database. . mysql_error()); mysql_select_db(SQL_DB, $conn); switch ($action) { case Create Character : $sql = INSERT IGNORE INTO char_zipcode (id, city, state) . VALUES ( $zip , $city , $state ) ; $result = mysql_query($sql) or die(mysql_error()); $sql = INSERT INTO char_lair (id, zip_id, lair_addr) . VALUES (NULL, $zip , $address ) ; $result = mysql_query($sql) or die(mysql_error()); if ($result) { $lairid = mysql_insert_id($conn); } $sql = INSERT INTO char_main (id,lair_id,alias,real_name,align) . VALUES (NULL, $lairid , $alias , $name , $align ) ; $result = mysql_query($sql) or die(mysql_error()); if ($result) { $charid = mysql_insert_id($conn); } if ($powers != ) { $val = ; foreach ($powers as $key => $id) { $val[] = ( $charid , $id ) ; } $values = implode( , , $val); $sql = INSERT IGNORE INTO char_power_link (char_id, power_id) . 291 Building Databases
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.

Leave a Reply