List:General Discussion« Previous MessageNext Message »
From:Mark Goodge Date:September 22 2009 8:56pm
Subject:Re: Wierd PHP/MySQL result
View as plain text  
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

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