Intereting Posts

Запросить URL-адрес Http

Я просто хочу вызвать script.php для управления базой данных, как опрос.

Вот мой код,

но он дает ошибку: не удается разрешить HttpClient.

HttpClient httpclient = new DefaultHttpClient(); httpclient.execute(new HttpGet("http://www.holobech.com/script.php")); 

также здесь my script.php, который проверяет время и создает таблицу каждый день:

 <?php require "includes/database.php"; require "classes/C_UserList.php"; require "classes/C_GlobalClass.php"; $current_game = GlobalClass::fetchinfo("value", "info", "name", "current_game"); $today = date("Ymd H:i:s"); $objUserList = new UserList; $game_started_at = $objUserList->getTotalTime($current_game); $diff = abs(strtotime($game_started_at . "+1 days") - strtotime($today)); $one_day = 60*60*24; if ($diff >= $one_day) { $db_connect = Database::connect(); $old_game = GlobalClass::fetchinfo("value", "info", "name", "current_game"); $new_game = $old_game + 1; $sql = "UPDATE info SET value = ? WHERE name = ?"; $query = $db_connect->prepare($sql); $query->execute(array($new_game, "current_game")); $sql = "CREATE TABLE game".$new_game."( id INT AUTO_INCREMENT PRIMARY KEY, uid INT NOT NULL, highlighting INT NOT NULL, sent_who INT NOT NULL, sent_amount VARCHAR(255) NOT NULL, sent_at DATETIME DEFAULT NULL, joined_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP )"; $query = $db_connect->prepare($sql); $query->execute(); $sql = "SELECT * FROM game".$old_game; $query = $db_connect->query($sql, PDO::FETCH_ASSOC); if ($query->rowCount() > 0) { $rows = $query->fetchAll(); if (count($rows) == 1) { $sql = "INSERT INTO game".$new_game." SET uid = ?, highlighting = ?"; $query = $db_connect->prepare($sql); $query->execute(array($rows[0]["uid"], $rows[0]["highlighting"])); $game_card = 1; $highlight_card = $rows[0]["highlighting"]; } else { for ($i = 0; $i < count($rows); $i++) { $sql = "SELECT played FROM user_game_info WHERE uid = ?"; $query = $db_connect->prepare($sql); $query->execute(array($rows[$i]["uid"])); $played = $query->fetch(); $sql = "UPDATE user_game_info SET at_game = ?, game_card = ?, played = ? WHERE uid = ?"; $query = $db_connect->prepare($sql); $query->execute(array("0", "0", $played["played"], $rows[$i]["uid"])); } $game_card = 0; $highlight_card = 0; } } else { $game_card = 0; $highlight_card = 0; } $sql = "INSERT INTO games SET game_id = ?, money_amount = ?, game_card = ?, highlight_card = ?, started_at = NOW()"; $query = $db_connect->prepare($sql); $query->execute(array($new_game, "0", $game_card, $highlight_card)); } ?>