I have a MySQL database hosted on a server. On table PERSON, I have the NAME column. One of the rows, has a name with the character "Ñ".
I'm working with a PHP Webservice that returns all the rows of that table, it works fine, but when one of the values contains a "Ñ", it returns null.
For Example: TABLE: Person. (ID - NAME) 1 - John 2 - Paul 3 - Iñaki
The PHP webservice returns Johm, Paul and null.
If I connect to the database from SQLyog or other software, I see the real values, John, Paul and Iñaki, so the problem is when the PHP Service returns the values of the table.
This is the PHP:
<?php
header('Content-type: application/json');
$server = "*****";
$username = "******";
$password = "********";
$database = "********";
$con = mysql_connect($server, $username, $password) or die ("Could not connect: " . mysql_error());
mysql_select_db($database, $con);
$sql = "SELECT * FROM person";
$result = mysql_query($sql) or die ("Query error: " . mysql_error());
$records = array();
while($row = mysql_fetch_assoc($result)) {
$records[] = $row;
}
mysql_close($con);
echo $_GET['jsoncallback'] . '(' . json_encode($records) . ');';
?>
Any help?