<?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>Leoganda.net</title>
	<atom:link href="http://www.leoganda.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.leoganda.net</link>
	<description></description>
	<lastBuildDate>Tue, 25 May 2010 16:33:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>The System Cannot Execute The Specified Program C++</title>
		<link>http://www.leoganda.net/the-system-cannot-execute-the-specified-program-c/</link>
		<comments>http://www.leoganda.net/the-system-cannot-execute-the-specified-program-c/#comments</comments>
		<pubDate>Tue, 25 May 2010 16:31:38 +0000</pubDate>
		<dc:creator>leoganda</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Error]]></category>

		<guid isPermaLink="false">http://www.leoganda.net/?p=76</guid>
		<description><![CDATA[Today I made a simple console application using Visual C++ 2008 and it was runs well on my development machine. But the problem occurred when I run the application on another machine, the error says &#8220;The system cannot execute the specified program&#8220;. I was guessing the problem occurred because of missing library or something, after [...]]]></description>
			<content:encoded><![CDATA[<p>Today I made a simple console application using Visual C++ 2008 and it was runs well on my development machine. But the problem occurred when I run the application on another machine, the error says &#8220;<strong>The system cannot execute the specified program</strong>&#8220;. I was guessing the problem occurred because of missing library or something, after short analysis both machine have the correct and the same library. So what&#8217;s going on??</p>
<p>I googled for this error and found <a href="http://blogs.msdn.com/b/nikolad/archive/2005/06/08/427101.aspx" target="_blank">this article</a>, it explains how this problem occurred on compiled C++ application. There&#8217;s two type of build on VC++ ( Debug and Release), my application was built in debug mode and <strong>we can&#8217;t re-distribute the application on debug mode</strong>. The built program in debug mode only runs on development machine, so in order to distribute my app I should build my application in &#8216;Release&#8217; mode. Time to switch from &#8216;Debug&#8217; to &#8216;Release&#8217; mode,</p>
<p>Open your <em>Visual Studio-&gt;(Open Project)-&gt;Project-&gt;(project name) properties</em></p>
<p><em>select the Build Tab, in configuration option choose &#8220;Release&#8221;.</em></p>
<p>Rebuild your project, you will find &#8220;Release&#8221; folder, your released application is in there.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leoganda.net/the-system-cannot-execute-the-specified-program-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Powershell FTP</title>
		<link>http://www.leoganda.net/simple-powershell-ftp/</link>
		<comments>http://www.leoganda.net/simple-powershell-ftp/#comments</comments>
		<pubDate>Mon, 03 May 2010 15:36:51 +0000</pubDate>
		<dc:creator>leoganda</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://www.leoganda.net/simple-powershell-ftp/</guid>
		<description><![CDATA[With Powershell we can do FTP transaction really easy. The best feature from Powershell is we can use any dll library in our script, we can import .Net libraries and etc into our script. The script below is simple FTP to upload file to FTP server. In this script I&#8217;m using System.Net.WebClient to handle the [...]]]></description>
			<content:encoded><![CDATA[<p>With Powershell we can do FTP transaction really easy. The best feature from Powershell is we can use any dll library in our script, we can import .Net libraries and etc into our script. The script below is simple FTP to upload file to FTP server. In this script I&#8217;m using System.Net.WebClient to handle the file transfer.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #800080;">$ftpuser</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;user&quot;</span>
<span style="color: #800080;">$ftppass</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;12345&quot;</span>
<span style="color: #800080;">$ftpserver</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;localhost&quot;</span>
<span style="color: #800080;">$file</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;C:\test.txt&quot;</span>
<span style="color: #800080;">$filenewname</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;test.txt&quot;</span>
&nbsp;
<span style="color: #800080;">$webclient</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Net.WebClient
<span style="color: #800080;">$ftp</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;ftp://&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$ftpuser</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;:&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$ftppass</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;@&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$ftpserver</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;/&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$filenewname</span>
<span style="color: #800080;">$uri</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Uri<span style="color: #000000;">&#40;</span><span style="color: #800080;">$ftp</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #800080;">$webclient</span>.UploadFile<span style="color: #000000;">&#40;</span><span style="color: #800080;">$uri</span><span style="color: pink;">,</span><span style="color: #800080;">$file</span><span style="color: #000000;">&#41;</span>﻿</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.leoganda.net/simple-powershell-ftp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Powershell script sort list file</title>
		<link>http://www.leoganda.net/powershell-script-sort-list-file/</link>
		<comments>http://www.leoganda.net/powershell-script-sort-list-file/#comments</comments>
		<pubDate>Mon, 03 May 2010 15:27:09 +0000</pubDate>
		<dc:creator>leoganda</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Powershell]]></category>

		<guid isPermaLink="false">http://www.leoganda.net/?p=69</guid>
		<description><![CDATA[It&#8217;s pretty easy to sort an output from ls or Get-ChildItem using powershell, you can sort the output by name, length, and date. Sort By Name Get-ChildItem C:\ &#124; sort -property Name Sort By Size Get-ChildItem C:\ &#124; sort -property Length Sort By Date Modified Get-ChildItem C:\ &#124; sort -property LastWriteTime You also can reorder [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s pretty easy to sort an output from ls or Get-ChildItem using powershell, you can sort the output by name, length, and date.</p>
<p>Sort By Name</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008080; font-weight: bold;">Get-ChildItem</span> C:\ <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">sort</span> <span style="color: #008080; font-style: italic;">-property</span> Name</pre></div></div>

<p>Sort By Size</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008080; font-weight: bold;">Get-ChildItem</span> C:\ <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">sort</span> <span style="color: #008080; font-style: italic;">-property</span> Length</pre></div></div>

<p>Sort By Date Modified</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008080; font-weight: bold;">Get-ChildItem</span> C:\ <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">sort</span> <span style="color: #008080; font-style: italic;">-property</span> LastWriteTime</pre></div></div>

<p>You also can reorder the sort output with &#8220;-descending&#8221;<br />
example :</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008080; font-weight: bold;">Get-ChildItem</span> C:\ <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">sort</span> <span style="color: #008080; font-style: italic;">-property</span> LastWriteTime <span style="color: #008080; font-style: italic;">-descending</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.leoganda.net/powershell-script-sort-list-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python for Windows Mobile</title>
		<link>http://www.leoganda.net/python-for-windows-mobile/</link>
		<comments>http://www.leoganda.net/python-for-windows-mobile/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 10:47:35 +0000</pubDate>
		<dc:creator>leoganda</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.leoganda.net/?p=60</guid>
		<description><![CDATA[Hello, right now I&#8217;m doing development some project using Python for my new company I&#8217;m working on. I thought Python will be boring, but Python changes my mind! As programming language Python is really simple and powerful. It can be run cross platform without compile anywhere. It runs well on my Windows and Linux, so [...]]]></description>
			<content:encoded><![CDATA[<p>Hello, right now I&#8217;m doing development some project using <a href="http://www.python.org" target="_blank">Python</a> for my new company I&#8217;m working on. I thought Python will be boring, but Python changes my mind! As programming language Python is really simple and powerful. It can be run cross platform without compile anywhere. It runs well on my Windows and Linux, so I was thinking could I install Python on my Windows Mobile device? The answer is YES! I&#8217;m using Windows mobile 6.1 and runs Python perfectly on it. If you want to install Python CE on your windows mobile device, you can get the CAB file in <a href="http://garr.dl.sourceforge.net/sourceforge/pythonce/PythonCE-25-20061219.PPC2003_ARM.CAB" target="_self">here</a>. It&#8217;s free.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leoganda.net/python-for-windows-mobile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setup was unable to open information file setupqry.inf</title>
		<link>http://www.leoganda.net/setup-was-unable-to-open-information-file-setupqry-inf/</link>
		<comments>http://www.leoganda.net/setup-was-unable-to-open-information-file-setupqry-inf/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 04:42:27 +0000</pubDate>
		<dc:creator>leoganda</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Error]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.leoganda.net/?p=57</guid>
		<description><![CDATA[Hi there, today I was trying to install IIS on my local computer and I got an error &#8220;Setup was unable to open information file setupqry.inf Contact your system admin. The specific error code is 0&#215;2 at line 0&#8220;. This problem occured after I upgrade my Windows XP SP2 to SP3. The error showed up [...]]]></description>
			<content:encoded><![CDATA[<p>Hi there, today I was trying to install IIS on my local computer and I got an error &#8220;<strong>Setup was unable to open information file setupqry.inf Contact your system admin. The specific error code is 0&#215;2 at line 0</strong>&#8220;.</p>
<p>This problem occured after I upgrade my Windows XP SP2 to SP3.</p>
<p>The error showed up because some file are missing when system upgraded to SP3. Here&#8217;s the list of missing file.</p>
<p><code><br />
<strong>setupqry.inf<br />
optional.inf<br />
msnmsn.inf</strong></code></p>
<p><code><strong>setupqry.dll<br />
msgrocm.dll<br />
ocmsn.dll</strong></code></p>
<p>Paste those inf file to your <code>Windows\inf</code> directory and paste the dll file to <code>windows\system32\setup</code>. It&#8217;s fix my problem.</p>
<p>You can <a href="http://www.leoganda.net/wp-content/uploads/2009/12/Windows.zip">download those file here,</a> just extract it to your windows directory.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leoganda.net/setup-was-unable-to-open-information-file-setupqry-inf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Auto Post Using Javascript</title>
		<link>http://www.leoganda.net/auto-post-using-javascript/</link>
		<comments>http://www.leoganda.net/auto-post-using-javascript/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 12:37:05 +0000</pubDate>
		<dc:creator>leoganda</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.leoganda.net/?p=51</guid>
		<description><![CDATA[Hi there, a few weeks ago I was doing research about auto post from webpage to paypal payment page. The basic idea is the visitor fill the form, then when the visitor submit the form we will store visitor data input to database. Once data stored in database the page will be automatically redirected to [...]]]></description>
			<content:encoded><![CDATA[<p>Hi there, a few weeks ago I was doing research about auto post from webpage to paypal payment page. The basic idea is the visitor fill the form, then when the visitor submit the form we will store visitor data input to database. Once data stored in database the page will be automatically redirected to paypal website. It&#8217;s pretty easy, we will use JavaScript to do auto post. I wanna make this article as simple as possible, I just wanna show how to do auto post with Javascript.<span id="more-51"></span></p>
<h3>1. Database</h3>
<p>We will use simple database for this experiment, single table with 4 columns ( id, first_name, last_name, package).</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`javascriptpost`</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">`sales`</span> <span style="color: #66cc66;">&#40;</span>
<span style="color: #ff0000;">`id`</span> INT<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">6</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span> <span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">`first_name`</span> VARCHAR<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">30</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">`last_name`</span> VARCHAR<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">30</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">`package`</span> VARCHAR<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">10</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">,</span>
<span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">`id`</span> <span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span> ENGINE <span style="color: #66cc66;">=</span> MYISAM ;</pre></div></div>

<h3>2. Form (index.php)</h3>
<p>First we need a basic form for user to input, data will be posted to post.php.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
	&lt;body&gt;
		&lt;form action=&quot;post.php&quot; method=&quot;post&quot;&gt;						
				&lt;p&gt;
				&lt;label&gt;First Name&lt;/label&gt;
				&lt;input type=&quot;text&quot; id=&quot;first_name&quot; name=&quot;first_name&quot;/&gt;
				&lt;/p&gt;
				&lt;p&gt;
				&lt;label&gt;Last Name&lt;/label&gt;
				&lt;input type=&quot;text&quot; id=&quot;last_name&quot; name=&quot;last_name&quot;/&gt;
				&lt;/p&gt;				
				&lt;p&gt;
				&lt;label&gt;Package&lt;/label&gt;
				&lt;select id=&quot;package&quot; name=&quot;package&quot;&gt;
					&lt;option value=&quot;A&quot;&gt;A&lt;/option&gt;
					&lt;option value=&quot;B&quot;&gt;B&lt;/option&gt;
					&lt;option value=&quot;C&quot;&gt;C&lt;/option&gt;
				&lt;/select&gt;
				&lt;/p&gt;				
				&lt;input type=&quot;submit&quot; value=&quot;submit&quot;/&gt;				
		&lt;/form&gt;
	&lt;body&gt;
&lt;/html&gt;</pre></div></div>

<h3>3. Post.php</h3>
<p>In post.php we will retrieve the posted data from index.php and store the data to database.<br />
Once data stored, the pages will be redirected to paypal website.</p>
<p>We will use javascript syntax to do autopost,</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script language<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;JavaScript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #003366; font-weight: bold;">var</span> time <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span>
<span style="color: #003366; font-weight: bold;">function</span> subm<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'paypal'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">submit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p><strong>post.php</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">isSet</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'first_name'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$firstname</span><span style="color: #339933;">=</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'first_name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$lastname</span><span style="color: #339933;">=</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'last_name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$package</span><span style="color: #339933;">=</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'package'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$package</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;A&quot;</span><span style="color: #339933;">:</span> <span style="color: #000088;">$amount</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>break<span style="color: #339933;">;</span>
		<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;B&quot;</span><span style="color: #339933;">:</span> <span style="color: #000088;">$amount</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">20</span><span style="color: #339933;">;</span>break<span style="color: #339933;">;</span>
		<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;C&quot;</span><span style="color: #339933;">:</span> <span style="color: #000088;">$amount</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">30</span><span style="color: #339933;">;</span>break<span style="color: #339933;">;</span>
		<span style="color: #b1b100;">default</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$amount</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;INSERT INTO sales (first_name,last_name,package) values ('<span style="color: #006699; font-weight: bold;">$firstname</span>','<span style="color: #006699; font-weight: bold;">$lastname</span>','<span style="color: #006699; font-weight: bold;">$package</span>')&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$con</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;localhost&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;root&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$con</span><span style="color: #009900;">&#41;</span>
	  <span style="color: #009900;">&#123;</span>
	  <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Could not connect: '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	  <span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;javascriptpost&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$con</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//insert to database</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;Home&lt;/title&gt;
&nbsp;
&lt;script language=&quot;JavaScript&quot;&gt;
var time = null
function subm() {
document.getElementById('paypal').submit();
}
&lt;/script&gt;
&nbsp;
&lt;/head&gt;
	&lt;body  onload=&quot;timer=setTimeout('subm()',2500)&quot;&gt;
        &lt;div id=&quot;content&quot;&gt;
  			&lt;center&gt;
            	&lt;h3&gt;Thank you for booking&lt;/h3&gt;                
                &lt;p&gt;Now we will redirect to payment page&lt;/p&gt;            
            &lt;/center&gt;
				&lt;form action=&quot;https://www.paypal.com/cgi-bin/webscr&quot; method=&quot;post&quot; onSubmit=&quot;&quot; name=&quot;paypal&quot; id=&quot;paypal&quot;&gt;
					    &lt;input type=&quot;hidden&quot; name=&quot;cmd&quot; value=&quot;_xclick&quot;&gt;
						&lt;input type=&quot;hidden&quot; name=&quot;business&quot; value=&quot;your-email@email.com&quot;&gt;
						&lt;input type=&quot;hidden&quot; name=&quot;item_name&quot; value=&quot;Package <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$package</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;
						&lt;input type=&quot;hidden&quot; name=&quot;amount&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$amount</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;
						&lt;input type=&quot;hidden&quot; name=&quot;currency_code&quot; value=&quot;USD&quot;&gt;
						&lt;input type=&quot;hidden&quot; name=&quot;return&quot; value=&quot;http://www.leoganda.net&quot;&gt;
						&lt;input type=&quot;hidden&quot; name=&quot;defined_quantity&quot; value=&quot;1&quot;&gt;
				&lt;/form&gt;
			&lt;/div&gt;&lt;!--content--&gt;
	&lt;/body&gt;
&lt;/html&gt;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.leoganda.net/auto-post-using-javascript/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Solving Zend Framework error &#8220;An Error Has Occurred A project profile was not found&#8221;</title>
		<link>http://www.leoganda.net/solving-zend-framework-error-an-error-has-occurred-a-project-profile-was-not-found/</link>
		<comments>http://www.leoganda.net/solving-zend-framework-error-an-error-has-occurred-a-project-profile-was-not-found/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 02:39:22 +0000</pubDate>
		<dc:creator>leoganda</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Error]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.leoganda.net/?p=47</guid>
		<description><![CDATA[Hi there, I had an error &#8220;An Error Has Occurred A project profile was not found&#8221; on Zend framework command line when I tried to generate an action for my project. I&#8217;m using Windows XP and for the web server I&#8217;m using XAMPP. The &#8220;An Error Has Occurred A project profile was not found&#8221; happened [...]]]></description>
			<content:encoded><![CDATA[<p>Hi there, I had an error &#8220;<strong>An Error Has Occurred A project profile was not found</strong>&#8221; on Zend framework command line when I tried to generate an action for my project. I&#8217;m using Windows XP and for the web server I&#8217;m using XAMPP. The &#8220;<strong>An Error Has Occurred A project profile was not found</strong>&#8221; happened because we have wrong include path in our php.ini.</p>
<p>Open your php.ini and find the include_path line, insert your zend framework library path into the line before the PEAR path.</p>
<p><code>include_path = ".;E:\xampp\htdocs\ZendFramework\library;E:\xampp\php\PEAR"</code></p>
<p>Save the file and restart your Apache. Good luck <img src='http://www.leoganda.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.leoganda.net/solving-zend-framework-error-an-error-has-occurred-a-project-profile-was-not-found/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>XML-RPC on IPhone</title>
		<link>http://www.leoganda.net/xml-rpc-on-iphone/</link>
		<comments>http://www.leoganda.net/xml-rpc-on-iphone/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 12:38:18 +0000</pubDate>
		<dc:creator>leoganda</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[IPhone]]></category>
		<category><![CDATA[XMLRPC]]></category>

		<guid isPermaLink="false">http://www.leoganda.net/?p=28</guid>
		<description><![CDATA[Hi, after play along to implement XML-RPC on IPhone finally I made it. I tried googling to find some articles that related to XML-RPC on IPhone, and those article drag me to WordPress application for IPhone. This application using XML RPC to communicate IPhone with the WordPress Blog, so the idea is grab the XML-RPC [...]]]></description>
			<content:encoded><![CDATA[<p>Hi, after play along to implement XML-RPC on IPhone finally I made it. I tried googling to find some articles that related to XML-RPC on IPhone, and those article drag me to WordPress application for IPhone. This application using XML RPC to communicate IPhone with the WordPress Blog, so the idea is grab the XML-RPC function from the WP application and implement it on our application. First we need to download WordPress for IPhone source code, you can <a href="http://iphone.trac.wordpress.org/changeset/336/tags/1.21?old_path=%2F&amp;format=zip" target="_blank">download it here.</a><span id="more-28"></span></p>
<p>Once you download the source code, extract it. You will find a folder named Class, under the Class folder you will find XMLRPC folder. We need to import this folder (with the file inside) to our project, and also import <strong>NSString+XMLExtensions.h</strong> and <strong>NSString+XMLExtensions.m.</strong></p>
<p>I will show you how to implement this XML-RPC on simple application.</p>
<p>Start your XCode program, make new &#8220;View-based Application&#8221; project.</p>
<p><a href="http://www.leoganda.net/wp-content/uploads/2009/08/Picture-1.png"><img title="Picture 1" src="http://www.leoganda.net/wp-content/uploads/2009/08/Picture-1.png" alt="Picture 1" width="409" height="159" /></a></p>
<p>Name the project with &#8220;XMLRPC-sayHello&#8221;.</p>
<p><a href="http://www.leoganda.net/wp-content/uploads/2009/08/Picture-2.png"><img title="Picture 2" src="http://www.leoganda.net/wp-content/uploads/2009/08/Picture-2.png" alt="Picture 2" width="480" height="93" /></a></p>
<p>Once the workspace opened, import the XMLRPC folder from WordPress source code to our project. Right click on Class folder, Add-&gt;Existing files</p>
<p><a href="http://www.leoganda.net/wp-content/uploads/2009/08/Picture-3.png"><img title="Picture 3" src="http://www.leoganda.net/wp-content/uploads/2009/08/Picture-3.png" alt="Picture 3" width="454" height="206" /></a></p>
<p>Then browse to the WordPress for Iphone source code, and select the XMLRPC folder. Click the &#8220;Add&#8221; button. The next is import the <strong>NSString+XMLExtensions.h</strong> and <strong>NSString+XMLExtensions.m </strong>files to our project.</p>
<p>Your project files will be look like this.</p>
<p><a href="http://www.leoganda.net/wp-content/uploads/2009/08/Picture-4.png"><img title="Picture 4" src="http://www.leoganda.net/wp-content/uploads/2009/08/Picture-4.png" alt="Picture 4" width="295" height="423" /></a></p>
<p>Ok the import step is done, now we need to design UI. We will make a simple interface with Label and Button only. The final design will be look like this.</p>
<p><a href="http://www.leoganda.net/wp-content/uploads/2009/08/Picture-5.png"><img title="Picture 5" src="http://www.leoganda.net/wp-content/uploads/2009/08/Picture-5-154x300.png" alt="Picture 5" width="154" height="300" /></a></p>
<p>To design the UI, double click the XMLRPC_SayHelloViewController.xib file and the interface builder will show up. On interface builder Drag a label from the library and change the text to &#8220;Response&#8221;. Next drag the Round Rect Button, and change the text to &#8220;Get Response&#8221;. Once done, close the interface builder and back to XCode.</p>
<h3>Coding</h3>
<p>Open the XMLRPC_SayHelloViewController.h, we will import the header files that used for XMLRPC, that are XMLRPCResponse.h, XMLRPCRequest.h, and XMLRPCConection.h. We also declare the label and the getResponse method in our header file. It should be look like this.</p>
<p><a href="http://www.leoganda.net/wp-content/uploads/2009/08/Picture-7.png"><img title="Picture 7" src="http://www.leoganda.net/wp-content/uploads/2009/08/Picture-7.png" alt="Picture 7" width="382" height="215" /></a></p>
<p>Once you done with the XMLRPC_SayHelloViewController.h, double click the XMLRPC_SayHelloViewController.xib to reopen the interface builder, we will connect the code with the interface. Open the Inspector window first Tools-&gt;Inspector.</p>
<p>Click the Response label in designer, then in the Inspector window it will be shown &#8220;New Referencing Outlet&#8221;. Drag the right circle of &#8220;New Referencing Outlet&#8221; to File&#8217;s Owner. See image.</p>
<p><a href="http://www.leoganda.net/wp-content/uploads/2009/08/Picture-81.png"><img title="Picture-8" src="http://www.leoganda.net/wp-content/uploads/2009/08/Picture-81.png" alt="Picture-8" width="618" height="303" /></a></p>
<p>When you release the mouse button, choose the &#8220;lblResponse&#8221; from the pop up window.</p>
<p><a href="http://www.leoganda.net/wp-content/uploads/2009/08/Picture-9.png"><img title="Picture 9" src="http://www.leoganda.net/wp-content/uploads/2009/08/Picture-9.png" alt="Picture 9" width="592" height="151" /></a></p>
<p>Ok, now select the Button on the interface, and drag the right circle button on the &#8220;Touch Down&#8221; inspector window to File&#8217;s Owner.</p>
<p><a href="http://www.leoganda.net/wp-content/uploads/2009/08/Picture-10.png"><img title="Picture 10" src="http://www.leoganda.net/wp-content/uploads/2009/08/Picture-10.png" alt="Picture 10" width="268" height="271" /></a></p>
<p>Once you finished editing the interface, save it and we continue with the coding.</p>
<p>Open the XMLRPC_SayHelloViewController.m and add the following code.</p>
<p><a href="http://www.leoganda.net/wp-content/uploads/2009/08/Picture-11.png"><img title="Picture 11" src="http://www.leoganda.net/wp-content/uploads/2009/08/Picture-11.png" alt="Picture 11" width="585" height="403" /></a></p>
<p>You can change the server path to your own path, and don&#8217;t forget to enable the XMLRPC on your wordpress installation. On wordpress XMLRPC there is demo.sayHello method that returns &#8220;hello&#8221; string, so I used this for the example.</p>
<p>Tadda! It&#8217;s done! Run the emulator by pressing command+enter button. Once running, press the &#8220;Get Response&#8221; button, that will invoke the getResponse method and show up the result to lblResponse.</p>
<p><a href="http://www.leoganda.net/wp-content/uploads/2009/08/XMLRPC-SayHello.zip">Download source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.leoganda.net/xml-rpc-on-iphone/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>How to enable XAMPP SSL socket transport</title>
		<link>http://www.leoganda.net/how-to-enable-xampp-ssl-socket-transport/</link>
		<comments>http://www.leoganda.net/how-to-enable-xampp-ssl-socket-transport/#comments</comments>
		<pubDate>Sun, 26 Jul 2009 13:37:06 +0000</pubDate>
		<dc:creator>leoganda</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[SSL]]></category>
		<category><![CDATA[XAMPP]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.leoganda.net/?p=24</guid>
		<description><![CDATA[Hi today I have an experiment with GData in Zend Framework PHP , and found an error that my XAMPP prevent SSL socket transport and return this error. Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Unable to Connect to ssl://www.google.com:443. Error #24: Unable to find the socket transport "ssl" - did you forget to enable [...]]]></description>
			<content:encoded><![CDATA[<p>Hi today I have an experiment with <a href="http://framework.zend.com/download/webservices" target="_blank">GData</a> in Zend Framework PHP , and found an error that my <a href="http://www.apachefriends.org/en/xampp.html" target="_blank">XAMPP </a>prevent SSL socket transport and return this error.</p>
<p><code>Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Unable to Connect to ssl://www.google.com:443. Error #24: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?'</code><span id="more-24"></span></p>
<p>Here&#8217;s the solution to make your XAMPP support socket transport SSL.<br />
1. First stop your Apache service<br />
2. Find <code>libeay32.dll</code> and <code>ssleay32.dll</code> in <code>xampp\php\</code> folder, and copy it into  <code>xampp\apache\bin\</code> folder. Just overwrite the older files in there.<br />
3. Edit <code>php.ini</code> file in <code>xampp\apache\bin</code>, remove the semicolon in &#8220;<code>;extension=php_openssl.dll</code>&#8221;<br />
4. Start the Apache service</p>
<p>That&#8217;s it, your SSL transport socket in your XAMPP has been activated.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leoganda.net/how-to-enable-xampp-ssl-socket-transport/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>How to connect MySQL in Prado Framework</title>
		<link>http://www.leoganda.net/how-to-connect-mysql-in-prado-framework/</link>
		<comments>http://www.leoganda.net/how-to-connect-mysql-in-prado-framework/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 16:00:55 +0000</pubDate>
		<dc:creator>leoganda</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Prado]]></category>

		<guid isPermaLink="false">http://www.leoganda.net/?p=8</guid>
		<description><![CDATA[Hello! This is my first article tutorial in this blog, today my friend have a problem connecting SQL databases with PRaDO framework. I have used this framework several years ago, and it&#8217;s quite easy to make a website with Prado. This time I will write how to connect MySQL with Prado, insert data, and display [...]]]></description>
			<content:encoded><![CDATA[<p>Hello!</p>
<p>This is my first article tutorial in this blog, today my friend have a problem connecting SQL databases with PRaDO framework. I have used this framework several years ago, and it&#8217;s quite easy to make a website with Prado. This time I will write how to connect MySQL with Prado, insert data, and display it in the web page.</p>
<p>First, I&#8217;m using XAMPPLITE as webserver, XAMPPLITE is lite version of XAMPP, but if you are using XAMPP it&#8217;s ok. <a title="Download XAMPP" href="http://www.apachefriends.org/en/xampp-windows.html" target="_blank">Download XAMPP</a>.</p>
<p>After you finish the XAMPP download, continue with download Prado framework. <a href="http://www.pradosoft.com/download/" target="_blank">Download Prado</a>.</p>
<p>Install the XAMPP, and extract the prado framework in htdocs folder.</p>
<p>The optional prado-cli.php PHP script file in the framework directory provides command line tools to perform various tedious takes in Prado. The prado-cli.php can be used to create Prado project skeletons, create initial test fixtures, and access to an interactive PHP shell. We will use command line tool to generate our prado project.<span id="more-8"></span></p>
<h3>1. Make setPath</h3>
<p>First I made setpath.bat to declare PHP path, so we can called any file in PHP path easier.</p>
<p>Make a file setpath.bat ( I put this file in C:\)</p>
<p><code>PATH=C:\xampplite\php\;</code></p>
<p>set the path to your php directory.</p>
<h3>2. Generate the Project</h3>
<p>Open the command prompt, and execute the setpath.bat by typing the filename setpath.bat</p>
<p><a href="http://www.leoganda.net/wp-content/uploads/2009/07/1-setpath.jpg"><img class="alignnone size-full wp-image-9" title="1 setpath" src="http://www.leoganda.net/wp-content/uploads/2009/07/1-setpath.jpg" alt="1 setpath" width="668" height="333" /></a></p>
<p>Go to htdocs</p>
<p><a href="http://www.leoganda.net/wp-content/uploads/2009/07/2-htdocs.jpg"><img class="alignnone size-full wp-image-10" title="2 htdocs" src="http://www.leoganda.net/wp-content/uploads/2009/07/2-htdocs.jpg" alt="2 htdocs" width="668" height="333" /></a></p>
<p>Let&#8217;s generate project, execute this line</p>
<p><code>php C:\xampplite\htdocs\prado\framework\prado-cli.php -c pradocontact</code></p>
<p>When the generate success the command line will display line like this</p>
<p><a href="http://www.leoganda.net/wp-content/uploads/2009/07/3-generate-project.jpg"><img class="alignnone size-full wp-image-11" title="3 generate project" src="http://www.leoganda.net/wp-content/uploads/2009/07/3-generate-project.jpg" alt="3 generate project" width="668" height="333" /></a></p>
<h3>3. Open in browser</h3>
<p>Open your browser and navigate to http://localhost/pradocontact/ if you see the prado welcome page, congratulations you have been generate prado project successly.</p>
<p><a href="http://www.leoganda.net/wp-content/uploads/2009/07/4-welcome-to-prado.jpg"><img class="alignnone size-full wp-image-12" title="4 welcome to prado" src="http://www.leoganda.net/wp-content/uploads/2009/07/4-welcome-to-prado.jpg" alt="4 welcome to prado" width="516" height="228" /></a></p>
<h3>4. Create Database</h3>
<p>Navigate to http://localhost/phpmyadmin/ and create new database. Type &#8220;pradocontact&#8221; in create new database field and hit create button.<br />
<a href="http://www.leoganda.net/wp-content/uploads/2009/07/5-create-database.jpg"><img src="http://www.leoganda.net/wp-content/uploads/2009/07/5-create-database.jpg" alt="5 create database" title="5 create database" width="578" height="260" class="alignnone size-full wp-image-13" /></a><br />
Then make a new table called &#8220;contact&#8221; with 2 field (id and name). Set the id field type into tinyint, auto_increment, and as primary key. Set the field name type as varchar and give the length 100.<br />
<a href="http://www.leoganda.net/wp-content/uploads/2009/07/6-create-table.jpg"><img src="http://www.leoganda.net/wp-content/uploads/2009/07/6-create-table.jpg" alt="6 create table" title="6 create table" width="439" height="122" class="alignnone size-full wp-image-14" /></a><br />
<a href="http://www.leoganda.net/wp-content/uploads/2009/07/7-field-table.jpg"><img src="http://www.leoganda.net/wp-content/uploads/2009/07/7-field-table.jpg" alt="7 field table" title="7 field table" width="554" height="104" class="alignnone size-full wp-image-15" /></a></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">&nbsp;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`contact`</span> <span style="color: #66cc66;">&#40;</span>
<span style="color: #ff0000;">`id`</span> TINYINT <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span> <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">`name`</span> VARCHAR<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">100</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>
<span style="color: #66cc66;">&#41;</span> ENGINE <span style="color: #66cc66;">=</span> MYISAM ;
&nbsp;
After the <span style="color: #993333; font-weight: bold;">TABLE</span> created<span style="color: #66cc66;">,</span> <span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #cc66cc;">2</span> rows <span style="color: #993333; font-weight: bold;">DATA</span> <span style="color: #993333; font-weight: bold;">INTO</span> contact <span style="color: #993333; font-weight: bold;">TABLE</span><span style="color: #66cc66;">.</span>
<span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`contact`</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">`id`</span> <span style="color: #66cc66;">,</span> <span style="color: #ff0000;">`name`</span> <span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span>
<span style="color: #ff0000;">'1'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'leo'</span>
<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #66cc66;">&#40;</span>
<span style="color: #ff0000;">'2'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'ganda'</span>
<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<h3>5. Set connection in application.xml</h3>
<p>Browse your project folder and open the protected folder C:\xampplite\htdocs\pradocontact\protected</p>
<p>You will see a file &#8220;application.xml&#8221;, open it and edit.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;modules<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;module</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;System.Data.TDataSourceConfig&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;database</span> <span style="color: #000066;">ConnectionString</span>=<span style="color: #ff0000;">&quot;mysql:host=localhost;dbname=pradocontact&quot;</span> <span style="color: #000066;">username</span>=<span style="color: #ff0000;">&quot;root&quot;</span> <span style="color: #000066;">password</span>=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/module<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;module</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;System.Data.ActiveRecord.TActiveRecordConfig&quot;</span> <span style="color: #000066;">ConnectionID</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/modules<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>We make a <strong>ConnectionString </strong>to mysql database, dbname is our database that used for this project. Set the <strong>username </strong>and <strong>password </strong>with your database account.</p>
<h3>6. Create Active Record</h3>
<p>To use active record, I will make a new folder called database inside the protected folder to store the <strong>ActiveRecord </strong>file. After the database folder created, open the <code>application.xml</code> once again, and declare the database path.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;paths<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;using</span> <span style="color: #000066;">namespace</span>=<span style="color: #ff0000;">&quot;Application.database.*&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/paths<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Your <code>application.xml</code> should be look like this</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;application</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;pradocontact&quot;</span> <span style="color: #000066;">mode</span>=<span style="color: #ff0000;">&quot;Debug&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;paths<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;using</span> <span style="color: #000066;">namespace</span>=<span style="color: #ff0000;">&quot;Application.database.*&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/paths<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
  <span style="color: #808080; font-style: italic;">&lt;!-- configurations for modules --&gt;</span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;modules<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;module</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;System.Data.TDataSourceConfig&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;database</span> <span style="color: #000066;">ConnectionString</span>=<span style="color: #ff0000;">&quot;mysql:host=localhost;dbname=pradocontact&quot;</span> <span style="color: #000066;">username</span>=<span style="color: #ff0000;">&quot;root&quot;</span> <span style="color: #000066;">password</span>=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/module<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;module</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;System.Data.ActiveRecord.TActiveRecordConfig&quot;</span> <span style="color: #000066;">ConnectionID</span>=<span style="color: #ff0000;">&quot;db&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/modules<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
&nbsp;
  <span style="color: #808080; font-style: italic;">&lt;!-- configuration for available services --&gt;</span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;services<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;service</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;page&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;TPageService&quot;</span> <span style="color: #000066;">DefaultPage</span>=<span style="color: #ff0000;">&quot;Home&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/services<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
  <span style="color: #808080; font-style: italic;">&lt;!-- application parameters</span>
<span style="color: #808080; font-style: italic;">  &lt;parameters&gt;</span>
<span style="color: #808080; font-style: italic;">    &lt;parameter id=&quot;param1&quot; value=&quot;value1&quot; /&gt;</span>
<span style="color: #808080; font-style: italic;">    &lt;parameter id=&quot;param2&quot; value=&quot;value2&quot; /&gt;</span>
<span style="color: #808080; font-style: italic;">  &lt;/parameters&gt;</span>
<span style="color: #808080; font-style: italic;">  --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/application<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>After you finish editing the <code>application.xml</code>, let&#8217;s generate Active Record from our database in MySQL.<br />
Open the command prompt again, go to C:\xampplite\htdocs\pradocontact\ and execute <code>php C:\xampplite\htdocs\prado\framework\prado-cli.php shell .</code></p>
<p>execute <code>generate contact Application.database.ContactRecord</code></p>
<p><a href="http://www.leoganda.net/wp-content/uploads/2009/07/8-generate-AR.jpg"><img src="http://www.leoganda.net/wp-content/uploads/2009/07/8-generate-AR.jpg" alt="8 generate AR" title="8 generate AR" width="668" height="333" class="alignnone size-full wp-image-16" /></a></p>
<p>Open your database folder with explorer, and you will find a new file called ContactRecord.php, try to open it.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Auto generated by prado-cli.php on 2009-07-18 03:01:37.
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> ContactRecord <span style="color: #000000; font-weight: bold;">extends</span> TActiveRecord
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">const</span> TABLE<span style="color: #339933;">=</span><span style="color: #0000ff;">'contact'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$id</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$name</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> finder<span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">__CLASS__</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> parent<span style="color: #339933;">::</span><span style="color: #004000;">finder</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h3>7. Test The Active Record</h3>
<p>Ok, let test our Active Record using command line tools, type &#8220;ContactRecord::finder()-&gt;findAll()&#8221; and hit enter. See the image below.<br />
<a href="http://www.leoganda.net/wp-content/uploads/2009/07/9-test-AR.jpg"><img src="http://www.leoganda.net/wp-content/uploads/2009/07/9-test-AR.jpg" alt="9 test AR" title="9 test AR" width="668" height="333" class="alignnone size-full wp-image-17" /></a><br />
The command line return an array with 2 record from the mySQL database and that means our activeRecord running well!</p>
<h3>8. Edit Home.page</h3>
<p>paste this code on your Home.page file<br />
<code><br />
&lt;%@ Title="Contact List" %&gt;</p>
<p>&lt;h1&gt;Contact List&lt;/h1&gt;</p>
<p>&lt;a href="&lt;%= $this-&gt;Service-&gt;constructUrl('insert')%&gt;"&gt;Create New Contact&lt;/a&gt;<br />
&lt;br/&gt;</p>
<p>&lt;com:TDataGrid ID="UserGrid"<br />
DataKeyField="id"<br />
AutoGenerateColumns="false"<br />
&gt;</p>
<p>&lt;com:TBoundColumn<br />
HeaderText="ID"<br />
DataField="id" /&gt;</p>
<p>&lt;com:TBoundColumn<br />
HeaderText="Name"<br />
DataField="name" /&gt;</p>
<p>&lt;/com:TDataGrid&gt;<br />
</code></p>
<h3>9. Make new file Home.php</h3>
<p>Paste this code on your Home.php</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> Home <span style="color: #000000; font-weight: bold;">extends</span> TPage
<span style="color: #009900;">&#123;</span>
    <span style="color: #009933; font-style: italic;">/**
     * Populates the datagrid with user lists.
     * This method is invoked by the framework when initializing the page
     * @param mixed event parameter
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> onInit<span style="color: #009900;">&#40;</span><span style="color: #000088;">$param</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        parent<span style="color: #339933;">::</span><span style="color: #004000;">onInit</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$param</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">// fetches all data account information</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">UserGrid</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">DataSource</span><span style="color: #339933;">=</span>ContactRecord<span style="color: #339933;">::</span><span style="color: #004000;">finder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">findAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">// binds the data to interface components</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">UserGrid</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dataBind</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h3>10. Make a new file insert.page</h3>
<p><code><br />
&lt;%@ Title="Insert Contact" %&gt;</p>
<p>&lt;com:TForm&gt;</p>
<p>&lt;h1&gt;Insert Contact&lt;/h1&gt;</p>
<p>&lt;span&gt;Name:&lt;/span&gt;<br />
&lt;br/&gt;<br />
&lt;com:TTextBox ID="Name" /&gt;</p>
<p>&lt;com:TButton Text="Create" OnClick="createButtonClicked" /&gt;</p>
<p>&lt;/com:TForm&gt;<br />
</code></p>
<h3>11. Make a new file insert.php</h3>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> insert <span style="color: #000000; font-weight: bold;">extends</span> TPage
<span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> createButtonClicked<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sender</span><span style="color: #339933;">,</span><span style="color: #000088;">$param</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">IsValid</span><span style="color: #009900;">&#41;</span>  <span style="color: #666666; font-style: italic;">// when all validations succeed</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// populates a UserRecord object with user inputs</span>
            <span style="color: #000088;">$ContactRecord</span><span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> ContactRecord<span style="color: #339933;">;</span>
            <span style="color: #000088;">$ContactRecord</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">=</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Name</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Text</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
            <span style="color: #666666; font-style: italic;">// saves to the database via Active Record mechanism</span>
            <span style="color: #000088;">$ContactRecord</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">// redirects the browser to the homepage</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirect</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Service</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">DefaultPageUrl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><a href="http://www.leoganda.net/wp-content/uploads/2009/07/10-file-structure.jpg"><img src="http://www.leoganda.net/wp-content/uploads/2009/07/10-file-structure.jpg" alt="10 file structure" title="10 file structure" width="497" height="337" class="alignnone size-full wp-image-18" /></a></p>
<p>Navigate your browser to <code>http://localhost/pradocontact/ </code>you will see this page<br />
<a href="http://www.leoganda.net/wp-content/uploads/2009/07/11-final.jpg"><img src="http://www.leoganda.net/wp-content/uploads/2009/07/11-final.jpg" alt="11 final" title="11 final" width="506" height="311" class="alignnone size-full wp-image-19" /></a></p>
<p>Ok, thanks for reading. Have a nice day! <img src='http://www.leoganda.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://www.leoganda.net/source/pradocontact.rar">Download Source</a><br />
<a href="http://www.leoganda.net/source/pradocontact.sql">Download SQL</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.leoganda.net/how-to-connect-mysql-in-prado-framework/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>
