<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ryan Price &#187; Facebook Platform</title>
	<atom:link href="http://www.ryanprice.ca/category/technology/facebook-platform/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ryanprice.ca</link>
	<description>The definitive proof that I'm a geek at heart</description>
	<lastBuildDate>Wed, 01 Sep 2010 18:23:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Connect with Facebook</title>
		<link>http://www.ryanprice.ca/connect-with-facebook/</link>
		<comments>http://www.ryanprice.ca/connect-with-facebook/#comments</comments>
		<pubDate>Sat, 27 Dec 2008 00:01:46 +0000</pubDate>
		<dc:creator>Ryan Price</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Facebook Platform]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Websites]]></category>
		<category><![CDATA[Social Networks]]></category>

		<guid isPermaLink="false">http://www.ryanprice.ca/?p=211</guid>
		<description><![CDATA[Facebook has recently extended their platform to allow you authenticate yourself from third party site like this one. In laymen&#8217;s terms, you can sign into my site with your Facebook account instead of registering. Go ahead an try it out, just click &#8220;Connect with Facebook&#8221; on the right hand menu. If you&#8217;d like, try leaving [...]<p>This post is from <a href="http://www.ryanprice.ca">Ryan Price's blog</a>.<br/><br/><a href="http://www.ryanprice.ca/connect-with-facebook/">Connect with Facebook</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Facebook has recently extended their platform to allow you authenticate yourself from third party site like this one.  In laymen&#8217;s terms, you can sign into my site with your Facebook account instead of registering.  Go ahead an try it out, just click &#8220;Connect with Facebook&#8221; on the right hand menu.</p>
<p>If you&#8217;d like, try leaving a comment to see how it works.</p>
<p>For those who want this ability on your site, I&#8217;m using a wordpress plugin found here: <a href="http://wiki.developers.facebook.com/index.php/WP-FBConnect" target="_blank">http://wiki.developers.facebook.com/index.php/WP-FBConnect</a> (by Facebook&#8217;s Adam Hupp).  I&#8217;ve modified and written a widget for it that I use here.  I&#8217;ve sent it to Adam and it should be available in future versions of the plug-in.  If you&#8217;d like it ahead of time drop me a line and I&#8217;ll send you the updated version now. </p>
<p>This post is from <a href="http://www.ryanprice.ca">Ryan Price&#8217;s blog</a>.<br/><br/><a href="http://www.ryanprice.ca/connect-with-facebook/">Connect with Facebook</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ryanprice.ca/connect-with-facebook/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Win $300 by Picking Stocks on Facebook</title>
		<link>http://www.ryanprice.ca/win-300-by-picking-stocks-on-facebook/</link>
		<comments>http://www.ryanprice.ca/win-300-by-picking-stocks-on-facebook/#comments</comments>
		<pubDate>Tue, 03 Jul 2007 16:07:37 +0000</pubDate>
		<dc:creator>Ryan Price</dc:creator>
				<category><![CDATA[Facebook Platform]]></category>

		<guid isPermaLink="false">http://www.ryanprice.ca/work/win-300-by-picking-stocks-on-facebook/</guid>
		<description><![CDATA[The Stock Picking Competition running on Facebook has its first sponsored competition. WebHostingBuzz.com has sponsored a 3-month competition and is putting up $300 to the winner. The Stock Picking Competition has grown to over 5500 users, with more joining every hour. This post is from Ryan Price&#8217;s blog.Win $300 by Picking Stocks on Facebook<p>This post is from <a href="http://www.ryanprice.ca">Ryan Price's blog</a>.<br/><br/><a href="http://www.ryanprice.ca/win-300-by-picking-stocks-on-facebook/">Win $300 by Picking Stocks on Facebook</a></p>
]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://uwo.facebook.com/apps/application.php?id=2374002577" target="_blank">Stock Picking Competition</a> running on Facebook has its first sponsored competition. WebHostingBuzz.com has sponsored a 3-month competition and is putting up $300 to the winner.</p>
<p>The Stock Picking Competition has grown to over 5500 users, with more joining every hour.</p>
<p>This post is from <a href="http://www.ryanprice.ca">Ryan Price&#8217;s blog</a>.<br/><br/><a href="http://www.ryanprice.ca/win-300-by-picking-stocks-on-facebook/">Win $300 by Picking Stocks on Facebook</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ryanprice.ca/win-300-by-picking-stocks-on-facebook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Avoid Problems with max_user_connections in PHP/SQL with 3 Simple Rules</title>
		<link>http://www.ryanprice.ca/how-to-avoid-problems-with-max_user_connections-in-phpsql-with-3-simple-rules/</link>
		<comments>http://www.ryanprice.ca/how-to-avoid-problems-with-max_user_connections-in-phpsql-with-3-simple-rules/#comments</comments>
		<pubDate>Thu, 14 Jun 2007 18:10:32 +0000</pubDate>
		<dc:creator>Ryan Price</dc:creator>
				<category><![CDATA[Facebook Platform]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.ryanprice.ca/work/how-to-avoid-problems-with-max_user_connections-in-phpsql-with-3-simple-rules/</guid>
		<description><![CDATA[Since the launch of my Fantasy Stock Picking Game for Facebook last weekend I've experienced a large increase in users (gone from about 60 to just under 3000). This meant that I had to make sure my code was as efficient as possible. Last night I took the time out to go through the code [...]<p>This post is from <a href="http://www.ryanprice.ca">Ryan Price's blog</a>.<br/><br/><a href="http://www.ryanprice.ca/how-to-avoid-problems-with-max_user_connections-in-phpsql-with-3-simple-rules/">How to Avoid Problems with max_user_connections in PHP/SQL with 3 Simple Rules</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Since the launch of my <a href="http://apps.facebook.com/stockpicking" target="_blank">Fantasy Stock Picking Game for Facebook</a> last weekend I've experienced a large increase in users (gone from about 60 to just under 3000).</p>
<p>This meant that I had to make sure my code was as efficient as possible.  Last night I took the time out to go through the code to ensure I hadn't overlooked anything.  Turns out I had, and it was causing <abbr title="The maximum number of connections you can have at one time to an SQL database">max_user_connections</abbr> to be exceeded (meaning some people would have problems accessing the game at certain points).</p>
<p>So in order to save yourself the hassle of going through your code like I did, let me help you cut the problem off at the pass and avoid it all together with a few simple rules:<br />
<span id="more-23"></span></p>
<h4>1. Open your connections just before you run the query, and close them immediately after.</h4>
<p>I was opening the connection at the beginning of a file, and then closing it at the end.  This meant that I was unnecessarily tying up a connection (and I only get 15) while information was being processed.</p>
<h4>2. Put your DB connection code in a function</h4>
<p>This ties in with the first suggestion.  Many people include the connection code in a header file or similar to ensure that the database connection is there when they need it.  This is inefficient.  Put your connection code into a function, call the function, and return the connection resource.</p>
<div class="igBar"><span id="lphp-2"><a href="#" onclick="javascript:showPlainTxt('php-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-2">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//Connect to the database</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> get_db_conn<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#0000FF;">$conn</span> = <a href="http://www.php.net/mysql_connect"><span style="color:#000066;">mysql_connect</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$GLOBALS</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'db_ip'</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#0000FF;">$GLOBALS</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'db_user'</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#0000FF;">$GLOBALS</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'db_pass'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> or <a href="http://www.php.net/die"><span style="color:#000066;">die</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"Unable to Connect to server"</span>. <a href="http://www.php.net/mysql_error"><span style="color:#000066;">mysql_error</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <a href="http://www.php.net/mysql_select_db"><span style="color:#000066;">mysql_select_db</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$GLOBALS</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'db_name'</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#0000FF;">$conn</span><span style="color:#006600; font-weight:bold;">&#41;</span> or <a href="http://www.php.net/die"><span style="color:#000066;">die</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"Unable to Connect to database"</span>. <a href="http://www.php.net/mysql_error"><span style="color:#000066;">mysql_error</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$conn</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h4>3. Remember that its not only <tt>mysql_query()</tt> that needs a connection!</h4>
<p>If you're using forms at all, you should be <a href="http://www.ryanprice.ca/work/how-to-make-your-form-data-safe-for-mysql-with-php/" target="_blank">ensuring that they are secure</a> before you use it in the database.  What many people don't know is that <tt>mysql_real_escape_string()</tt> needs an active connection to the database to work, so make sure that you have an open connection before using this function.</p>
<p>This post is from <a href="http://www.ryanprice.ca">Ryan Price's blog</a>.<br/><br/><a href="http://www.ryanprice.ca/how-to-avoid-problems-with-max_user_connections-in-phpsql-with-3-simple-rules/">How to Avoid Problems with max_user_connections in PHP/SQL with 3 Simple Rules</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ryanprice.ca/how-to-avoid-problems-with-max_user_connections-in-phpsql-with-3-simple-rules/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebook Stock Picking Competition</title>
		<link>http://www.ryanprice.ca/facebook-stock-picking-competition/</link>
		<comments>http://www.ryanprice.ca/facebook-stock-picking-competition/#comments</comments>
		<pubDate>Sun, 03 Jun 2007 20:33:55 +0000</pubDate>
		<dc:creator>Ryan Price</dc:creator>
				<category><![CDATA[Facebook Platform]]></category>

		<guid isPermaLink="false">http://www.ryanprice.ca/work/facebook-stock-picking-competition/</guid>
		<description><![CDATA[It has been a little longer then usual in between posts here, but there is good reason. I have been working many hours over the last couple weeks making a stock picking competition that runs on Facebook's platform. The game is simply called Stock Picking Competition. Although there are many other features I plan on [...]<p>This post is from <a href="http://www.ryanprice.ca">Ryan Price's blog</a>.<br/><br/><a href="http://www.ryanprice.ca/facebook-stock-picking-competition/">Facebook Stock Picking Competition</a></p>
]]></description>
			<content:encoded><![CDATA[<p>It has been a little longer then usual in between posts here, but there is good reason.</p>
<p>I have been working many hours over the last couple weeks making a <a href="http://uwo.facebook.com/apps/application.php?id=2374002577">stock picking competition</a> that runs on <a href="http://blog.facebook.com/blog.php?post=2437282130" target="_blank">Facebook's platform</a>.</p>
<p>The game is simply called <strong>Stock Picking Competition</strong>.  Although there are many other features I plan on adding, the general idea is as follows:</p>
<p>You install put the application onto your Facebook profile.  Then you choose which competitions you want to enter.  For each competition you join, you are given a portfolio with the stated starting amount of cash.  From there, you can buy and sell stocks whenever you want (although trades are only executed during market hours).</p>
<p>You can view your standing in the competition, and your profile will show your portfolios to friends.  Go ahead and <a href="http://uwo.facebook.com/apps/application.php?id=2374002577">try the stock picking competition</a>.</p>
<p>Let me know what you like, what you don't like, what you'd like to see added, etc.</p>
<p>This post is from <a href="http://www.ryanprice.ca">Ryan Price's blog</a>.<br/><br/><a href="http://www.ryanprice.ca/facebook-stock-picking-competition/">Facebook Stock Picking Competition</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ryanprice.ca/facebook-stock-picking-competition/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
