Exemplo n.º 1
0
        if (!$db) {
            echo json_encode(array('testing' => true, 'result' => 'error', 'error_msg' => 'Error connecting to the MySQL server.'));
            return;
        }
        $opendb = @mysql_select_db($db_config['name'], $db);
        if (!$opendb) {
            echo json_encode(array('testing' => true, 'result' => 'error', 'error_msg' => 'Error selecting the database.'));
            return;
        }
        $sql = "SELECT email FROM users where id=1";
        $rs = @mysql_query($sql, $db);
        if (!$rs) {
            echo json_encode(array('testing' => true, 'result' => 'error', 'error_msg' => 'Error executing query: "' . $sql . '"'));
            return;
        }
        $data = mysql_fetch_object($rs);
        if (!$data) {
            echo json_encode(array('testing' => true, 'result' => 'error', 'error_msg' => 'Error fetching the resulting object.'));
        }
        mysql_free_result($rs);
        mysql_close($db);
        unset($rs, $sql);
        echo json_encode(array('testing' => true, 'result' => 'success', 'data' => $data));
    }
}
$registrationController = new Registration();
if (isset($_GET['test'])) {
    $registrationController->testWebservice();
} else {
    $registrationController->invoke();
}