<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: MySQL to JSON with PHP</title>
	<atom:link href="http://www.emanueleferonato.com/2009/09/23/mysql-to-json-with-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.emanueleferonato.com/2009/09/23/mysql-to-json-with-php/</link>
	<description>italian geek and PROgrammer</description>
	<lastBuildDate>Fri, 10 Feb 2012 12:12:29 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>By: GeoBob</title>
		<link>http://www.emanueleferonato.com/2009/09/23/mysql-to-json-with-php/#comment-858376</link>
		<dc:creator>GeoBob</dc:creator>
		<pubDate>Tue, 21 Jun 2011 11:40:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=1677#comment-858376</guid>
		<description>I think there is an errant semicolon on line 31 of your code.  I don&#039;t think there should be a semicolon inside the quotation marks. Take it out, and you get JSON code that validates.

Thanks for your post!  It&#039;s been extremely helpful.</description>
		<content:encoded><![CDATA[<p>I think there is an errant semicolon on line 31 of your code.  I don&#8217;t think there should be a semicolon inside the quotation marks. Take it out, and you get JSON code that validates.</p>
<p>Thanks for your post!  It&#8217;s been extremely helpful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jocuri</title>
		<link>http://www.emanueleferonato.com/2009/09/23/mysql-to-json-with-php/#comment-703706</link>
		<dc:creator>jocuri</dc:creator>
		<pubDate>Mon, 13 Dec 2010 14:52:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=1677#comment-703706</guid>
		<description>caleb, it tried your code, and is not working</description>
		<content:encoded><![CDATA[<p>caleb, it tried your code, and is not working</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Caleb Wright</title>
		<link>http://www.emanueleferonato.com/2009/09/23/mysql-to-json-with-php/#comment-502443</link>
		<dc:creator>Caleb Wright</dc:creator>
		<pubDate>Thu, 24 Sep 2009 16:37:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=1677#comment-502443</guid>
		<description>PHP 5.2+ has a function called json_encode(). So you can shorten everything to this:

function mysql2json($mysql_result,$name) {
	$result = array($name =&gt; array());
	while ($row = mysql_fetch_assoc($mysql_result))
		$result[$name][] = $row;
	return json_encode($result);
}

(I haven&#039;t tested it, but it should work).</description>
		<content:encoded><![CDATA[<p>PHP 5.2+ has a function called json_encode(). So you can shorten everything to this:</p>
<p>function mysql2json($mysql_result,$name) {<br />
	$result = array($name =&gt; array());<br />
	while ($row = mysql_fetch_assoc($mysql_result))<br />
		$result[$name][] = $row;<br />
	return json_encode($result);<br />
}</p>
<p>(I haven&#8217;t tested it, but it should work).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephen McIntyre</title>
		<link>http://www.emanueleferonato.com/2009/09/23/mysql-to-json-with-php/#comment-502266</link>
		<dc:creator>Stephen McIntyre</dc:creator>
		<pubDate>Thu, 24 Sep 2009 08:00:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=1677#comment-502266</guid>
		<description>One thing I&#039;d suggest would be to add the line $count_names = count($field_names); after the line beginning with $rows = mysql_num... and refer all of your references to count($field_names) instead to the $count_names var.

Otherwise you call the count() function twice for every occurence of $x in each $y, which can add up, especially if you&#039;re querying the number of fields and values in a database.

Otherwise, keep up the great posts, especially with PHP :)</description>
		<content:encoded><![CDATA[<p>One thing I&#8217;d suggest would be to add the line $count_names = count($field_names); after the line beginning with $rows = mysql_num&#8230; and refer all of your references to count($field_names) instead to the $count_names var.</p>
<p>Otherwise you call the count() function twice for every occurence of $x in each $y, which can add up, especially if you&#8217;re querying the number of fields and values in a database.</p>
<p>Otherwise, keep up the great posts, especially with PHP :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ransom Weaver</title>
		<link>http://www.emanueleferonato.com/2009/09/23/mysql-to-json-with-php/#comment-502159</link>
		<dc:creator>Ransom Weaver</dc:creator>
		<pubDate>Thu, 24 Sep 2009 00:38:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=1677#comment-502159</guid>
		<description>Don&#039;t forget AMFPHP&#039;s great JSON gateway. If you have an AMFPHP service e.g. &quot;getMyStuff&quot; a call to the gateway will return a JSON version. Example:

function getMyStuff($usr,$pwd) {
 // get the stuff with php from mysql
 return $mySqlResult;
}

example JSON call:

http://somesite.com/amfphp/myservices/getMyStuff/myusrname/mypwd

You can also set this up to use POST vars instead of inline GET</description>
		<content:encoded><![CDATA[<p>Don&#8217;t forget AMFPHP&#8217;s great JSON gateway. If you have an AMFPHP service e.g. &#8220;getMyStuff&#8221; a call to the gateway will return a JSON version. Example:</p>
<p>function getMyStuff($usr,$pwd) {<br />
 // get the stuff with php from mysql<br />
 return $mySqlResult;<br />
}</p>
<p>example JSON call:</p>
<p><a href="http://somesite.com/amfphp/myservices/getMyStuff/myusrname/mypwd" rel="nofollow">http://somesite.com/amfphp/myservices/getMyStuff/myusrname/mypwd</a></p>
<p>You can also set this up to use POST vars instead of inline GET</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Database Caching 1/11 queries in 0.103 seconds using disk: basic

Served from: www.emanueleferonato.com @ 2012-02-10 21:29:08 -->
