List:General Discussion« Previous MessageNext Message »
From:Mogens Melander Date:September 22 2009 9:11pm
Subject:Re: Wierd PHP/MySQL result
View as plain text  
Yes, you are right. It's the json_encode that fail.

It's strange though. The data that fail is "Humlebæk".

Another query, in another form, returning "Værksted" don't
fail in json_encode.

echo $cust['oname'];    give the correct value.

On Tue, September 22, 2009 22:56, Mark Goodge wrote:
> Mogens Melander wrote:
>> Well, no typos.
>>
>> The relevant piece of code:
>>
>> if (! $cust = mysql_fetch_assoc($res))
>> {
>> 	echo "{success: false, errors: { reason: 'Fetch Customer failed: " .
>> 		htmlspecialchars(mysql_error(),ENT_QUOTES) .
>> 		"<br>" . htmlspecialchars($sql,ENT_QUOTES) . "'}}";
>> }
>> else
>> {
>> 	echo "{success: true, total: 1, results:[" . json_encode($cust) . "]}";
>> }
>>
>
> What happens if you simplify the PHP?
>
>
> $cust = mysql_fetch_assoc($res);
> print_r($cust);
>
>
> That will tell you what PHP is seeing from MySQL. If the results have
> the correct values, then the problem is elsewhere in the code.
>
> I suspect that the problem is in the json_encode() function. According
> to the PHP documentation this requires utf8-encoded data. If your values
> in oname are not utf8, then that may explain why the function is
> returning a 'null' where it should have a string.
>
> Mark
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
>
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>


-- 
Later

Mogens Melander



-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Thread
Wierd PHP/MySQL resultMogens Melander22 Sep
Re: Wierd PHP/MySQL resultMogens Melander22 Sep
  • Re: Wierd PHP/MySQL result (Solved)Mogens Melander22 Sep
  • Re: Wierd PHP/MySQL resultMark Goodge22 Sep
    • Re: Wierd PHP/MySQL resultMogens Melander22 Sep