Good morning
I'm trying to use Python to connect to a MySQL Database, so I'm trying to use a GET request and a PHP script.
The code I have so far is:
Thanks
Chris
I'm trying to use Python to connect to a MySQL Database, so I'm trying to use a GET request and a PHP script.
The code I have so far is:
import requests import json print 'Hello, World' url = 'https://www.thebar.inthepub.co.uk/resttest.php' response = requests.get(url) dict = response.json() print (dict)This then links to a file with the following:
<?php echo '<p>test</p>'; $myObj->name = "John"; $myObj->age = 30; $myObj->city = "New York"; $myJSON = json_encode($myObj); echo $myJSON; ?>But when I run it, I get an error, 'No JSON Object could be decoded'. Any ideas why? Is it my code, or is there another module I need to install?
Thanks
Chris