Why I Can't Retrieve Data From My Webserver As Json But I Can When I Test It On Localhost
I'm trying to create a simple login app that connects to mysql database. The app works find when i test it in localhost , but when i uploaded the database and the php scripts to a
Solution 1:
I had a similar problem a while ago, I do not know why but I managed to solve using echo json_encode ( $ response , JSON_UNESCAPED_UNICODE ) ;
instead ofprint
and escaping special characters in encode instead of mysqli , hope it helps
Solution 2:
Seems the problem was with the hosting itself, I tried another hosting (arvixe) and everything works as charm. i have no idea why but maybe because it is a payed hosting.
Solution 3:
Many of the free hosting provider are appending the analytics code at the end, that is the major reason why php files fails.
The best solution for this type of problem is to use
<?phpexit(); ?>
after the last executable statement, which will explicitly close the PHP file.
When you exit explicitly PHP file, the code will not be appended to the JSON.
Post a Comment for "Why I Can't Retrieve Data From My Webserver As Json But I Can When I Test It On Localhost"