xml output:


how to fetch the xml output from url and store the credits i.e. 39660 into php variable.
the above xml output is coming from following url


check-balance.php code:

$username = $_GET['username'];
$password = $_GET['password'];
$password = encrypt($password, 'riffre');
$url = $_SERVER['HTTP_HOST'];
$url_length = strlen($url);

if (substr($url, 0, 4) == 'www.') {
    $url_length = $url_length - 4;
    $url = substr( $url, 4, $url_length );

$query = "select * from users where username='$username' and password='$password' and status='Active'";

if(!($result = mysql_query($query))) {
$userid = $crq['id'];

$rows = mysql_num_rows($result);
if ($rows != 1) {
    echo 'Invalid Credentials.';
    return 1;
$avail = check_user_credit($userid);

header('Content-Type: application/xml');
echo "<balance><credits>$avail</credits></balance>";

hope some one will resolve this issue.

thanks in advance

Recommended Answers

All 5 Replies

my code output is in xml not in json

Yes you are right ;) . Then @see http://php.net/manual/en/simplexml.examples-basic.php (of course you will add an ?xml start tag (as in the example there) and also var_export first the results to be sure what you got).

Just a question did you Googled it ?

So , is this solved ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.