public static function connect($host, $name, $wachtwoord, $db, $makedb = false) { if (empty($host) || empty($name) || empty($wachtwoord) || empty($db)) { //return false; } self::$database = $db; //Used @ phpbb plugin self::$db = @mysql_connect($host, $name, $wachtwoord); if (self::$db === false) { return self::$db; } else { if ($makedb === true) { $sql = "CREATE DATABASE " . $db; if (!@mysql_query($sql, self::$db)) { st_die(SQL, "ERROR CREATING DB", "", __LINE__, __FILE__, $sql); self::sql_close(); return false; } } self::$db2 = @mysql_select_db($db, self::$db); if (self::$db2 === false) { self::sql_close(); return self::$db2; } else { return self::$db; } } }
public static function connect($host, $username, $password, $dbname, $makedb = false) { if (empty($host) || empty($username) || empty($password) || empty($dbname)) { //return false; } self::$database = $dbname; //Used @ phpbb plugin self::$db = new PDO("mysql:host={$host};dbname={$dbname}", $username, $password); if (self::$db === false) { return self::$db; } else { if ($makedb === true) { $sql = "CREATE DATABASE " . $dbname; if (!self::$db->query($sql, self::$dbname)) { return false; } } } }
</center> <?php } elseif ($_GET['do'] == 'check_item') { $matrix = unserialize($_GET['matrix']); $i = $_GET['i']; $j = $_GET['j']; $a = $_GET['a']; echo $size; $game1 = new HQ_Sudoku($size); $game1->grid = $matrix; $valid = $game1->valid_item($i, $j, $a); if ($valid) { $game1->set_item($i, $j, $a); //save to db $db = new mysql('sql311.summerhost.info', 'sum_6305668', '1671988'); $db->db('sum_6305668_test'); $db->query("update sudoku set grid='" . $game1->matrix_string() . "'"); echo '<textarea>' . $game1->matrix_string() . ($game1->is_full_matrix() ? '[DONE]' : '') . '</textarea>'; echo '<script>test.get_line(1).content("' . valid_str_in_str($game1->suggest_result(false, 'ok')) . '");</script>'; exit; } else { //out1($i.'-'.$j); $game1->remove_item($i, $j); echo '<textarea>' . $game1->matrix_string() . '[FALSE]</textarea>'; exit; } } elseif ($_GET['do'] == 'suggest_item') { $i = $_GET['i']; $j = $_GET['j']; $matrix_origin = unserialize($_GET['matrix_origin']); $matrix = unserialize($_GET['matrix']);