<?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>Antonio Ciccarone &#187; Code</title>
	<atom:link href="http://blog.antoniociccarone.com/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.antoniociccarone.com</link>
	<description>Life, Code and Music</description>
	<lastBuildDate>Thu, 15 Jul 2010 18:07:15 +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 to MySQL Function</title>
		<link>http://blog.antoniociccarone.com/connect-to-mysql-function/</link>
		<comments>http://blog.antoniociccarone.com/connect-to-mysql-function/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 21:27:21 +0000</pubDate>
		<dc:creator>Antonio Ciccarone</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[connect]]></category>
		<category><![CDATA[connection]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.antoniociccarone.com/?p=158</guid>
		<description><![CDATA[Connect to a MySQL database.  Download the zip with all related php files. <a href="http://blog.antoniociccarone.com/connect-to-mysql-function/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is how I connect to a MySQL database.  The following code is based off of three or four separate php files but could <strong>insecurely</strong> be combined into one.  We&#8217;ll be creating functions.php which holds all of the code that the site uses, settings.php which holds the configurable options and a connection.php that connects to the database.  The fourth and obviously optional file is your index.php (or wherever you&#8217;re connecting from)</p>
<p>First, in functions.php we&#8217;ll define our connectSQL.  It takes four arguments and connects or returns an error if unsuccessful</p>
<div id="code">

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p158code1'); return false;">View Code</a> LANGUAGE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1581"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code" id="p158code1"><pre class="language" style="font-family:monospace;">function connectSQL($server, $user, $pass, $name) {
	define(&quot;DB_SERVER&quot;, $server);define(&quot;DB_USER&quot;, $user);define(&quot;DB_PASS&quot;, $pass);define(&quot;DB_NAME&quot;, $name);
	$connection = mysql_connect(DB_SERVER,DB_USER,DB_PASS);
	if (!$connection) {
		die(&quot;Database connection failed: &quot; . mysql_error());
	}
	$db_select = mysql_select_db(DB_NAME,$connection);
	if (!$db_select) {
		die(&quot;Database selection failed: &quot; . mysql_error());
	}
}</pre></td></tr></table></div>

</div>
<p>In settings.php we&#8217;ll assign values to the variables.  Always remember to use secure passwords.</p>
<div id="code">

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p158code2'); return false;">View Code</a> LANGUAGE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1582"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p158code2"><pre class="language" style="font-family:monospace;">// Database Configuration
$database['server'] = &quot;localhost&quot;;
$database['user'] = &quot;xxx&quot;;
$database['password'] = &quot;xxx&quot;;
$database['name'] = &quot;xxx&quot;;</pre></td></tr></table></div>

</div>
<p>The actual connection code is now pretty easy to implement.  You can call it whenever and however you&#8217;d like with only one line of code.</p>
<div id="code">

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p158code3'); return false;">View Code</a> LANGUAGE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1583"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p158code3"><pre class="language" style="font-family:monospace;">// Connection to the database via function
connectSQL($database['server'], $database['user'], $database['password'], $database['name']);</pre></td></tr></table></div>

</div>
<p>Finally, to actually use this, simply include the connection.php</p>
<div id="code">

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p158code4'); return false;">View Code</a> LANGUAGE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1584"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p158code4"><pre class="language" style="font-family:monospace;">include 'connection.php';</pre></td></tr></table></div>

</div>
<p><a href="downloads/Connect to MySQL Function.zip"><img src="images/downloadCode.png" border="0" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.antoniociccarone.com/connect-to-mysql-function/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Morning</title>
		<link>http://blog.antoniociccarone.com/morning/</link>
		<comments>http://blog.antoniociccarone.com/morning/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 13:43:46 +0000</pubDate>
		<dc:creator>Antonio Ciccarone</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Life]]></category>
		<category><![CDATA[crm]]></category>
		<category><![CDATA[jacob]]></category>
		<category><![CDATA[jaiden]]></category>
		<category><![CDATA[morning]]></category>
		<category><![CDATA[wife]]></category>

		<guid isPermaLink="false">http://blog.antoniociccarone.com/morning/</guid>
		<description><![CDATA[I&#8217;m outside smoking a cigarette before it&#8217;s time to wake the family up. Happy Good Friday, if I&#8217;m not mistaken Jesus died today. I hear snoring coming through a neighbors window to the left and a sickly alarm clock vomiting &#8230; <a href="http://blog.antoniociccarone.com/morning/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m outside smoking a cigarette before it&#8217;s time to wake the family up.  Happy Good Friday, if I&#8217;m not mistaken Jesus died today.  I hear snoring coming through a neighbors window to the left and a sickly alarm clock vomiting in 4/5.  </p>
<p>Half-day at work today, we might go see &#8216;how to train your dragon&#8217; after we pick up the boys from Sheena&#8217;s parents&#8217; house.  Jacob started preschool this week, he seems to really like it and got into the flow of things very quickly.  Jaiden is off for Spring Vacation all week starting today, I&#8217;m sure he&#8217;s souped.</p>
<p>The CRM demo went well, I&#8217;m 60% complete with the first scope!  My online voting application went online this week for council testing, got some pretty high praise from the guinea pigs.  Made it mobile yesterday per request.  It has it&#8217;s own session based authentication now along with a bunch of other bells and whistles.  </p>
<p>Four minutes til&#8217; opening &#8211; can&#8217;t wait to see the wife go into mommy-mode.  Better wash my smokey hands now.</p>
<p><a href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fblog.antoniociccarone.com%2Fmorning%2F&amp;linkname=Morning" title="Facebook" rel="nofollow" target="_blank"><img src="http://blog.antoniociccarone.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a> <a href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fblog.antoniociccarone.com%2Fmorning%2F&amp;linkname=Morning" title="Twitter" rel="nofollow" target="_blank"><img src="http://blog.antoniociccarone.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a> <a href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fblog.antoniociccarone.com%2Fmorning%2F&amp;linkname=Morning" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://blog.antoniociccarone.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a> <a href="http://www.addtoany.com/add_to/google_buzz?linkurl=http%3A%2F%2Fblog.antoniociccarone.com%2Fmorning%2F&amp;linkname=Morning" title="Google Buzz" rel="nofollow" target="_blank"><img src="http://blog.antoniociccarone.com/wp-content/plugins/add-to-any/icons/google_buzz.png" width="16" height="16" alt="Google Buzz"/></a> <a href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fblog.antoniociccarone.com%2Fmorning%2F&amp;linkname=Morning" title="Delicious" rel="nofollow" target="_blank"><img src="http://blog.antoniociccarone.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a> <a href="http://www.addtoany.com/add_to/stumbleupon?linkurl=http%3A%2F%2Fblog.antoniociccarone.com%2Fmorning%2F&amp;linkname=Morning" title="StumbleUpon" rel="nofollow" target="_blank"><img src="http://blog.antoniociccarone.com/wp-content/plugins/add-to-any/icons/stumbleupon.png" width="16" height="16" alt="StumbleUpon"/></a> <a href="http://www.addtoany.com/add_to/ping?linkurl=http%3A%2F%2Fblog.antoniociccarone.com%2Fmorning%2F&amp;linkname=Morning" title="Ping" rel="nofollow" target="_blank"><img src="http://blog.antoniociccarone.com/wp-content/plugins/add-to-any/icons/ping.png" width="16" height="16" alt="Ping"/></a> <a href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fblog.antoniociccarone.com%2Fmorning%2F&amp;linkname=Morning" title="Digg" rel="nofollow" target="_blank"><img src="http://blog.antoniociccarone.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a> <a href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fblog.antoniociccarone.com%2Fmorning%2F&amp;linkname=Morning" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://blog.antoniociccarone.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a> <a href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fblog.antoniociccarone.com%2Fmorning%2F&amp;linkname=Morning" title="Reddit" rel="nofollow" target="_blank"><img src="http://blog.antoniociccarone.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a> <a href="http://www.addtoany.com/add_to/yahoo_buzz?linkurl=http%3A%2F%2Fblog.antoniociccarone.com%2Fmorning%2F&amp;linkname=Morning" title="Yahoo Buzz" rel="nofollow" target="_blank"><img src="http://blog.antoniociccarone.com/wp-content/plugins/add-to-any/icons/buzz.png" width="16" height="16" alt="Yahoo Buzz"/></a> <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save">Share Me</a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.antoniociccarone.com/morning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting my feet RET</title>
		<link>http://blog.antoniociccarone.com/getting-my-feet-ret/</link>
		<comments>http://blog.antoniociccarone.com/getting-my-feet-ret/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 19:31:26 +0000</pubDate>
		<dc:creator>Antonio Ciccarone</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[real estate]]></category>
		<category><![CDATA[rets]]></category>

		<guid isPermaLink="false">http://blog.antoniociccarone.com/?p=19</guid>
		<description><![CDATA[Today I'll be connecting to a Postgres database for the first time.   I'm used to mySQL but I hear they're basically the same when it comes down to functionality. <a href="http://blog.antoniociccarone.com/getting-my-feet-ret/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today I&#8217;ll be connecting to a Postgres database for the first time.   I&#8217;m used to mySQL but I hear they&#8217;re basically the same when it comes down to functionality.   I&#8217;ve already started working on <a title="Ajax-Based Property Search" href="http://dev.urbiance.com/ajax/" target="_blank">an AJAX based property search</a> with some sample data, so I just have to take my code off of dev.urbiance and hook it into our server.</p>
<p>I&#8217;m also a virgin to remote databases, it looks like the connection is working &#8211; but I haven&#8217;t queried or echoed anything yet.  So far I&#8217;ve got a Javascript price slider, city selector and zip code input which send an XMLHttp request to a php page, query the property table and send the response text back into a div.  Going for a completely object-oriented code structure here, wish me luck.  I&#8217;ll be updating my progress and snippets along the way here on my blog.</p>
<p>
<span class="signature">Happy remote coding, Antonio</span></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.antoniociccarone.com/getting-my-feet-ret/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
