I am currently using Phonegap with xcode to create an iPhone application.
I'm just trying to just call Json to get a query from a database (php) and it returns Null.
I have a domain whitelist in a .plist file for a phone call. Here is the m code:
$.getJSON('"http://slc0013.pickaweb.co.uk/~bengeor1/fixtures.php",', function(data) {
alert(data);
$('#resultLog').html("<p>item1="+data.id+" item2="+data.home_team+" item3="+data.away_team+"</p>");
});
PHP code:
<?php
header("Access-Control-Allow-Origin: *");
ini_set('display_errors',1);
error_reporting(E_ALL);
header('Cache-Control: no-cache, must-revalidate');
header('Content-type: application/json');
$db = "localhost";
$db_name = "xxx";
$db_user = "xxx";
$db_pwd = "xxxx";
$con = mysql_connect($db, $db_user, $db_pwd);
if (!$con) {
$status = 11;
}
$db_selected = mysql_select_db($db_name, $con);
if (!$db_selected) {
}
$query = "SELECT * FROM Fixtures";
$result = mysql_query($query);
mysql_close();
$num = mysql_numrows($result);
$rows = array();
while($r = mysql_fetch_assoc($result)) {
$rows[] = $r;
}
echo json_encode($rows)
?>
If you run only the php file, it will display the correct results.
Thank your help.
Thank.
source
share