php is not generating json object but some html code

Shashank
edited November -1 in Support Forums

Here are the php files :

(connection.php)

<?php
define('hostname','sql203.ezyro.com');
define('user','ezyro_19243512');
define('password','********');
define('databaseName','ezyro_19243512_kmvonline');
$connect=mysql_connect(hostname,user,password,databaseName);
?>

(showNotification.php)

<?php
if($_SERVER["REQUEST_METHOD"]=="GET")
{
include 'connection.php';
showNotification();        
}
function showNotification()
{
global $connect;
$query = "SELECT * FROM ezyro_19243512_kmvonline.collegeNotification ORDER    BY id DESC";
$result = mysql_query($query,$connect);
$number_of_rows=mysql_num_rows($result);
$temp_array=array();   
if($number_of_rows>0)
{
    while($row=mysql_fetch_assoc($result)){
        $temp_array[]=$row;
    }
}  
header('Content-Type: application/json');
echo json_encode(array("collegeNotifications"=>$temp_array));
mysql_close($connect);
}
?>

From here i want the json object to my app...
http://shashanksingh.ezyro.com/php/showNotifications.php

It is showing the correct json data

{
    "collegeNotifications":[
    {
        "id":"3",
        "title":"no title",
        "description":"no description",
        "department":"0",
        "day":"1",
        "month":"1"
    },
    {
        "id":"2",
        "title":"no title",
        "description":"no description",
        "department":"0",
        "day":"1",
        "month":"1"
    },
    {
        "id":"1",
        "title":"no title",
        "description":"no description",
        "department":"0",
        "day":"1",
        "month":"1"
    }
    ]
}

But in my android app and even in postman application I am receiving this HTML code :

<html>
    <body>
        <script type="text/javascript" src="/aes.js" ></script>
        <script>function toNumbers(d){var e=[];d.replace(/(..)/g,function(d){e.push(parseInt(d,16))});return e}function toHex(){for(var d=[],d=1==arguments.length&&arguments[0].constructor==Array?arguments[0]:arguments,e="",f=0;f
            <d.length;f++)e+=(16>d[f]?"0":"")+d[f].toString(16);return e.toLowerCase()}var a=toNumbers("f655ba9d09a112d4968c63579db590b4"),b=toNumbers("98344c2eee86c3994890592585b49f80"),c=toNumbers("0e5a2729453a722e4baeba76f6b3c3a0");document.cookie="__test="+toHex(slowAES.decrypt(c,2,a,b))+"; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/"; location.href="http://shashanksingh.ezyro.com/php/showNotifications.php?i=1";
            </script>
            <noscript>This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support</noscript>
        </body>
    </html>    

Comments

  • Admin
    edited November -1

    i am using a php file to generate json object which is accessed by my app in browser i am getting this :

    {"collegeNotifications":[{"id":"3","title":"no title","description":"no description","department":"0","day":"1","month":"1"},{"id":"2","title":"no title","description":"no description","department":"0","day":"1","month":"1"},{"id":"1","title":"no title","description":"no description","department":"0","day":"1","month":"1"}]}

    which is exactly what i want but in my android app i am receiving this html code :

    function toNumbers(d){var e=[];d.replace(/(..)/g,function(d){e.push(parseInt(d,16))});return e}function toHex(){for(var d=[],d=1==arguments.length&&arguments[0].constructor==Array?arguments[0]:arguments,e="",f=0;f<d.length;f++)e+=(16>d[f]?"0":"")+d[f].toString(16);return e.toLowerCase()}var a=toNumbers("f655ba9d09a112d4968c63579db590b4"),b=toNumbers("98344c2eee86c3994890592585b49f80"),c=toNumbers("0e5a2729453a722e4baeba76f6b3c3a0");document.cookie="__test="+toHex(slowAES.decrypt(c,2,a,b))+"; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/"; location.href="http://shashanksingh.ezyro.com/php/showNotifications.php?i=1";This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support

    Need HELP!!!!!!!!!

    If you provide more details like what api you are using, where it is showing the results and where it is not, and also the php code, it will be easier to understand the issue and help.

  • Shashank
    edited November -1

    Here are the php files :

    (connection.php)

    <?php
    define('hostname','sql203.ezyro.com');
    define('user','ezyro_19243512');
    define('password','********');
    define('databaseName','ezyro_19243512_kmvonline');
    $connect=mysql_connect(hostname,user,password,databaseName);
    ?>
    

    (showNotification.php)

    <?php
    if($_SERVER["REQUEST_METHOD"]=="GET")
    {
    include 'connection.php';
    showNotification();        
    }
    function showNotification()
    {
    global $connect;
    $query = "SELECT * FROM ezyro_19243512_kmvonline.collegeNotification ORDER    BY id DESC";
    $result = mysql_query($query,$connect);
    $number_of_rows=mysql_num_rows($result);
    $temp_array=array();   
    if($number_of_rows>0)
    {
        while($row=mysql_fetch_assoc($result)){
            $temp_array[]=$row;
        }
    }  
    header('Content-Type: application/json');
    echo json_encode(array("collegeNotifications"=>$temp_array));
    mysql_close($connect);
    }
    ?>
    

    From here i want the json object to my app...
    http://shashanksingh.ezyro.com/php/showNotifications.php

    It is showing the correct json data

    {
        "collegeNotifications":[
        {
            "id":"3",
            "title":"no title",
            "description":"no description",
            "department":"0",
            "day":"1",
            "month":"1"
        },
        {
            "id":"2",
            "title":"no title",
            "description":"no description",
            "department":"0",
            "day":"1",
            "month":"1"
        },
        {
            "id":"1",
            "title":"no title",
            "description":"no description",
            "department":"0",
            "day":"1",
            "month":"1"
        }
        ]
    }
    

    But in my android app and even in postman application I am receiving this HTML code :

    <html>
        <body>
            <script type="text/javascript" src="/aes.js" ></script>
            <script>function toNumbers(d){var e=[];d.replace(/(..)/g,function(d){e.push(parseInt(d,16))});return e}function toHex(){for(var d=[],d=1==arguments.length&&arguments[0].constructor==Array?arguments[0]:arguments,e="",f=0;f
                <d.length;f++)e+=(16>d[f]?"0":"")+d[f].toString(16);return e.toLowerCase()}var a=toNumbers("f655ba9d09a112d4968c63579db590b4"),b=toNumbers("98344c2eee86c3994890592585b49f80"),c=toNumbers("0e5a2729453a722e4baeba76f6b3c3a0");document.cookie="__test="+toHex(slowAES.decrypt(c,2,a,b))+"; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/"; location.href="http://shashanksingh.ezyro.com/php/showNotifications.php?i=1";
                </script>
                <noscript>This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support</noscript>
            </body>
        </html>