//return array_key_exists($POST_key, $_GET) ? $_GET[$POST_key] : $defaultValue; return array_key_exists($POST_key, $_POST) ? $_POST[$POST_key] : $defaultValue; } $fn = lookupWithDefault('fn', ""); $ln = lookupWithDefault('ln', ""); $addr1 = lookupWithDefault('addr1', ""); $addr2 = lookupWithDefault('addr2 ', ""); $city = lookupWithDefault('city', ""); $st = lookupWithDefault('st', ""); $zip = lookupWithDefault('zip', ""); $ph = lookupWithDefault('ph', ""); $email = lookupWithDefault('email', ""); //TEST: //$bookName = $_GET['bookName']; $bookName = $_POST['bookName']; touchBook($bookName); // ============================================================================ // Connect to and modify the database. // ============================================================================ // Call this with debug info if connection fails or database not found. function accessFail($debug) { global $scriptSuccess, $idOut, $scriptDebug; $scriptSuccess = False; $idOut = -1; $scriptDebug = $debug; scriptOutput(); die; } // Connect to the MySQL server process. //TODO: Use a .cnf file instead of hardcoding the MySQL login.
<?php include_once '../utils.php'; $dbName = 'panda_address_book'; mysql_connect('ix-trusty:3022', 'xunl', 'tbc123bl') or accessFail("Could not connect: " . mysql_error()); mysql_select_db($dbName) or accessFail("Could not find database: " . mysql_error()); /* $tableName = 'book_names'; $sql = "SELECT * FROM $tableName"; // Select all, sorted. $queryResult = mysql_query($sql); while($row = mysql_fetch_assoc($queryResult)) { print_r($row); echo '<br>'; } */ echo doesBookExist('my friends') ? 'my friends' : 'stop 1'; echo '<br>'; echo doesBookExist('friends contacts') ? 'friends contacts' : 'stop 2'; echo '<br>'; echo touchBook('friends contacts') ? 'friends contacts' : 'stop 3'; mysql_close();