<?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>Mukesh Chapagain&#039;s Blog &#187; code</title>
	<atom:link href="http://blog.chapagain.com.np/tag/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.chapagain.com.np</link>
	<description>PHP Magento jQuery SQL Wordpress Joomla Programming &#38; Tutorial</description>
	<lastBuildDate>Tue, 07 Feb 2012 00:54:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Using database in PEAR and Smarty</title>
		<link>http://blog.chapagain.com.np/using-database-in-pear-and-smarty/</link>
		<comments>http://blog.chapagain.com.np/using-database-in-pear-and-smarty/#comments</comments>
		<pubDate>Fri, 18 Jul 2008 06:00:57 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[PEAR]]></category>
		<category><![CDATA[Smarty]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[mdb2]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=71</guid>
		<description><![CDATA[For using database, you need to install a package of PEAR called ‘MDB2’ along with the installation of PEAR and Smarty. MDB2 provides a common API for all support RDBMS. Connecting to database To connect to a database through PEAR::MDB2, you have to create a valid DSN &#8211; data source name. This DSN consists in [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/file-upload-in-pear-and-smarty/' rel='bookmark' title='Permanent Link: File Upload in PEAR and Smarty'>File Upload in PEAR and Smarty</a></li>
<li><a href='http://blog.chapagain.com.np/pagination-in-pear-and-smarty/' rel='bookmark' title='Permanent Link: Pagination in PEAR and Smarty'>Pagination in PEAR and Smarty</a></li>
<li><a href='http://blog.chapagain.com.np/installing-the-smarty-template-engine/' rel='bookmark' title='Permanent Link: Installing the Smarty Template Engine'>Installing the Smarty Template Engine</a></li>
<li><a href='http://blog.chapagain.com.np/an-introduction-to-pear/' rel='bookmark' title='Permanent Link: An Introduction to PEAR'>An Introduction to PEAR</a></li>
<li><a href='http://blog.chapagain.com.np/backup-and-recovery-of-mysql-database/' rel='bookmark' title='Permanent Link: Backup and Recovery of MySQL database'>Backup and Recovery of MySQL database</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>For using database, you need to install a package of PEAR called ‘MDB2’ along with the installation of <a title="Installing PEAR" href="http://pear.php.net/manual/en/installation.php" target="_blank">PEAR</a> and <a title="Installing Smarty" href="http://blog.chapagain.com.np/index.php/2008/07/11/installing-the-smarty-template-engine/" target="_blank">Smarty</a>.</p>
<p>MDB2 provides a common API for all support RDBMS.</p>
<p><span id="more-71"></span></p>
<p><strong>Connecting to database</strong></p>
<p>To connect to a database through PEAR::MDB2, you have to create a valid <acronym>DSN &#8211; data source name</acronym>. This DSN consists in the following parts:</p>
<p class="MsoNormal" style="text-align: justify;">phptype: Database backend used in PHP (i.e. mysql , pgsql etc.)</p>
<p class="MsoNormal" style="text-align: justify;">dbsyntax: Database used with regards to SQL syntax etc.</p>
<p class="MsoNormal" style="text-align: justify;">protocol: Communication protocol to use ( i.e. tcp, unix etc.)</p>
<p class="MsoNormal" style="text-align: justify;">hostspec: Host specification (hostname[:port])</p>
<p class="MsoNormal" style="text-align: justify;">database: Database to use on the DBMS server</p>
<p class="MsoNormal" style="text-align: justify;">username: User name for login</p>
<p class="MsoNormal" style="text-align: justify;">password: Password for login</p>
<p class="MsoNormal" style="text-align: justify;">proto_opts: Maybe used with protocol</p>
<p class="MsoNormal" style="text-align: justify;">option: Additional connection options in URI query string format. options get separated by &amp;.</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">The DSN can either be provided as an associative array or as a string. The string format of the supplied DSN is in its fullest form:</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;"><em>phptype(dbsyntax)://username:password@protocol+hostspec/database?option=value</em></p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">To instantiate a database object you have several methods available using MDB2.</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;"><em>factory()</em> : Will instantiate a new <span>MDB2_Driver_Common</span> instance, but will not connect to the database until required. This will delay making the actual connection.</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;"><em>connect()</em> : Will instantiate a new <span>MDB2_Driver_Common</span> instance, and will establish a database connection immediately. This way any connection issues will immediately raise an error.</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;"><em>singleton()</em> : Returns a MDB2_Driver_Common instance.</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">A new MDB2_Driver_Common object is only created once using <em>factory()</em>, subsequent calls to singleton will return a reference to the existing object. This method is preferred over declaring your database object as a global.</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">To connect to a database you have to use the function <em>factory()</em>, <em>connect()</em> or <em>singleton()</em>, which require a valid DSN as the first parameter. This parameter can either be a string or an array. The second parameter is the optional $options array that can contain runtime configuration settings for this package.</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">I have used the <em>connect()</em> function with the DSN as</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;"><em>phptype://username:password@hostspec/database</em></p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">
<pre class="brush: php; title: ; notranslate">$mdb2 =&amp; MDB2::connect('mysql://root:@localhost/test');</pre>
</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">In my case, the database backend is mysql, database username is root, database password is null, the hostname is localhost and the database name is test.</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;"><strong>Querying the database</strong></p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">PEAR MDB2 provides several methods for querying databases. The most direct method is query(). It takes a SQL query string as an argument. There are two possible returns: A new MDB2_Result object for queries that return results (such as SELECT queries), or a MDB2_Error object on failure. It should not be used with statements that manipulate data (such as INSERT queries).</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">exec() should be used for manipulation queries. There are two possible returns: An integer denoting the number of affected rows for statements that manipulate data (such as INSERT queries), or a MDB2_Error object on failure. It should not be used with statements that return results (such as SELECT queries).</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">Here, I will only be dealing with the SELECT queries.</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">
<pre class="brush: php; title: ; notranslate">$mdb2 = new ConnectMDB2;&lt;/p&gt;
// calling the function conMDB2 of ConnectMDB2 class
$connect = $mdb2-&gt;conMDB2();&lt;/p&gt;
$res = $connect-&gt;query(&quot;SELECT * FROM basic&quot;);
</pre>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;"><strong> </strong></p>
<p class="MsoNormal" style="text-align: justify;"><strong>Fetching result</strong></p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">The MDB2_Result_Common object provides four methods for fetching data from rows of a result set: fetchOne(), fetchRow(), fetchCol() and fetchAll().</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">fetchRow() and fetchOne() read an entire row or a single field from a column respectively. The result pointer gets moved to the next row each time these methods are called. NULL is returned when the end of the result set is reached.</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">fetchAll() and fetchCol() read all rows in the result set and therefore move the result pointer to the end. While fetchAll() reads the entire row data, fetchCol() only reads a single column.</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">MDB2_Error is returned if an error is encountered.</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">I have used the fetchRow() method. The fetchmode MDB2_FETCHMODE_ASSOC is used for fetching data. The default fetchmode is MDB2_FETCHMODE_ORDERED.</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">
<pre class="brush: php; title: ; notranslate">while($row[] = $res-&gt;fetchRow(MDB2_FETCHMODE_ASSOC))
{
$result = $row;
}
</pre>
</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">If there is any error then the error message is displayed in a separate template called error.tpl. And if there is no error while fetching data then the fetched result is displayed in the template file index.tpl.</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">
<pre class="brush: php; title: ; notranslate">if(PEAR::isError($res))
{
// get error message
$error =&amp; $res-&gt;getMessage();&lt;/p&gt;
// assign error message
$smarty-&gt;assign('errmessage',$error);&lt;/p&gt;
// display the message and exit
$smarty-&gt;display('error.tpl');
exit();
}&lt;/p&gt;
// asign the content
$smarty-&gt;assign('result',$result);

// display the content
$smarty-&gt;display('index.tpl');
</pre>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">In the template file, <em>foreach</em> loop is used to display the result.</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">
<pre class="brush: xml; title: ; notranslate">{foreach from=$result item=view}
&lt;tr bgcolor=&quot;{cycle values=&quot;#ffffff,#eeeeee&quot;}&quot;&gt;
&lt;td&gt;{$view.firstname}&lt;/td&gt;
&lt;td&gt;{$view.lastname}&lt;/td&gt;
&lt;/tr&gt;
{/foreach}
</pre>
</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;"><strong><span><a title="Download Source Code" href="http://chapagain.googlecode.com/files/database_pear_smarty.zip">Download source code</a></span></strong></p>
<p class="MsoNormal" style="text-align: justify;"><span> </span></p>
<p class="MsoNormal" style="text-align: justify;"><span>Note: <em>I have not included Smarty library files in this zip file. You can download the Smarty library files from </em></span><a title="Download Smarty" href="http://smarty.php.net/download.php" target="_blank">http://smarty.php.net/download.php</a><span><em> or directly from </em></span><a href="http://chapagain.googlecode.com/files/smarty.zip">http://chapagain.googlecode.com/files/smarty.zip</a></p>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small><img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=71&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/file-upload-in-pear-and-smarty/' rel='bookmark' title='Permanent Link: File Upload in PEAR and Smarty'>File Upload in PEAR and Smarty</a></li>
<li><a href='http://blog.chapagain.com.np/pagination-in-pear-and-smarty/' rel='bookmark' title='Permanent Link: Pagination in PEAR and Smarty'>Pagination in PEAR and Smarty</a></li>
<li><a href='http://blog.chapagain.com.np/installing-the-smarty-template-engine/' rel='bookmark' title='Permanent Link: Installing the Smarty Template Engine'>Installing the Smarty Template Engine</a></li>
<li><a href='http://blog.chapagain.com.np/an-introduction-to-pear/' rel='bookmark' title='Permanent Link: An Introduction to PEAR'>An Introduction to PEAR</a></li>
<li><a href='http://blog.chapagain.com.np/backup-and-recovery-of-mysql-database/' rel='bookmark' title='Permanent Link: Backup and Recovery of MySQL database'>Backup and Recovery of MySQL database</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/using-database-in-pear-and-smarty/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to get(view) html source code of a website</title>
		<link>http://blog.chapagain.com.np/how-to-get-html-source-code-of-a-website/</link>
		<comments>http://blog.chapagain.com.np/how-to-get-html-source-code-of-a-website/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 12:49:52 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/?p=65</guid>
		<description><![CDATA[In this article, I will be illustrating about getting html source code of any website. I have done this in PHP. I created an html form for submitting the website url. After the url is submitted, the PHP code does all the magic to display full html source code of that particular website. The source [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/how-to-change-the-source-code-and-modifyparse-a-website/' rel='bookmark' title='Permanent Link: How to change the source code and modify/parse a website?'>How to change the source code and modify/parse a website?</a></li>
<li><a href='http://blog.chapagain.com.np/php-read-write-csv/' rel='bookmark' title='Permanent Link: PHP: Read Write CSV'>PHP: Read Write CSV</a></li>
<li><a href='http://blog.chapagain.com.np/php-source-code-encoding-with-ioncube-php-encoder/' rel='bookmark' title='Permanent Link: PHP source code encoding with ionCube PHP Encoder'>PHP source code encoding with ionCube PHP Encoder</a></li>
<li><a href='http://blog.chapagain.com.np/javascript-add-remove-html-elements/' rel='bookmark' title='Permanent Link: Javascript: Add Remove HTML elements'>Javascript: Add Remove HTML elements</a></li>
<li><a href='http://blog.chapagain.com.np/creating-dynamic-table-in-php/' rel='bookmark' title='Permanent Link: Creating dynamic table in PHP : Easy and Simple tutorial'>Creating dynamic table in PHP : Easy and Simple tutorial</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>In this article, I will be illustrating about getting html source code of any website. I have done this in PHP.</p>
<p class="MsoNormal" style="text-align: justify;">
<p><span id="more-65"></span></p>
<p class="MsoNormal" style="text-align: justify;">I created an html form for submitting the website url. After the url is submitted, the PHP code does all the magic to display full html source code of that particular website. The source code is displayed in a textarea.</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;"><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning /> <w:ValidateAgainstSchemas /> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:BreakWrappedTables /> <w:SnapToGridInCell /> <w:WrapTextWithPunct /> <w:UseAsianBreakRules /> <w:DontGrowAutofit /> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--></p>
<p class="MsoNormal" style="text-align: justify;"><!--[if gte mso 10]></p>
<style>
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:"Table Normal";
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-parent:"";
	mso-padding-alt:0in 5.4pt 0in 5.4pt;
	mso-para-margin:0in;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Times New Roman";
	mso-ansi-language:#0400;
	mso-fareast-language:#0400;
	mso-bidi-language:#0400;}
</style>
<p><![endif]--></p>
<p class="MsoNormal" style="text-align: justify;"><span style="color: purple;">$domain = $_POST['domain'];</span></p>
<p class="MsoNormal" style="text-align: justify;"><span style="color: purple;">$handle = fopen(&#8220;http://$domain&#8221;,&#8221;r&#8221;);</span></p>
<p class="MsoNormal" style="text-align: justify;"><span style="color: purple;">//$contents = stream_get_contents($handle);</span></p>
<p class="MsoNormal" style="text-align: justify;"><span style="color: purple;">$contents = &#8221;;</span></p>
<p class="MsoNormal" style="text-align: justify;"><span style="color: purple;">while (!feof($handle)) {</span></p>
<p class="MsoNormal" style="text-align: justify;"><span style="color: purple;">$contents .= fread($handle, 8192);</span></p>
<p class="MsoNormal" style="text-align: justify;"><span style="color: purple;">} </span></p>
<p class="MsoNormal" style="text-align: justify;"><span style="color: purple;">fclose($handle);</span></p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">At first the website url submitted through the html form is opened with <em>fopen()</em>. Then, using <em>while</em> loop, the <em>$contents</em> string variable is populated (concatenated) until the end of file is reached. Finally, the file/url pointer is closed with <em>fclose()</em>.</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">You can also get all the contents without using loop. You can get it with the stream_get_contents() function. But this function is only supported by PHP 5+. <em><span lang="EN">stream_get_contents()</span></em><span lang="EN"> operates on an already open stream resource and returns the remaining contents in a string. <em>stream_get_contents()</em> will not work in PHP versions lower than PHP 5. If you are using PHP versions lower than PHP 5, then better not use it.</span></p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;"><strong>Description of functions used:</strong></p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;"><em>fopen()</em> opens the url. The mode used here (i.e. ‘r’) is read mode.</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;"><em>feof()</em> tests for end-of-file on a file pointer. It returns true if the file pointer is at EOF; otherwise it returns false.</p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;"><em><span lang="EN">fread()</span></em><span lang="EN"> reads up to <var>length</var> bytes from the file pointer referenced by <var>handle</var>. Reading stops when up to <var>length</var> bytes have been read, EOF (end of file) is reached, (for network streams) when a packet becomes available, or (after opening userspace stream) when 8192 bytes have been read whichever comes first. </span></p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;"><em><span lang="EN">fclose()</span></em><span lang="EN"> closes an open file pointer.</span></p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;"><span lang="EN"><a title="HTML Source Code Viewer" href="http://chapagain.com.np/codeviewer.php" target="_blank">View it live</a></span></p>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">Full <span lang="EN">source code:</span></p>
<p style="text-align: justify;">
<pre class="brush: php; title: ; notranslate">&lt;?php
if(isset($_POST['submit']))
{
$domain = $_POST['domain'];
$handle = fopen(&quot;http://$domain&quot;,&quot;r&quot;);
//$contents = stream_get_contents($handle);
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
//var_dump($contents);
}&lt;/p&gt;
?&gt;&lt;/p&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;HTML Source Code Viewer&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;&lt;/p&gt;
&lt;h2&gt;
HTML Source Code Viewer
&lt;/h2&gt;&lt;/p&gt;
&lt;form method=&quot;post&quot; name=&quot;pageform&quot; action=&quot;&quot; onsubmit=&quot;return validate(this);&quot;&gt;&lt;/p&gt;
&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse&quot; width=&quot;&quot;&gt;
&lt;tr&gt;
&lt;td width=&quot;&quot; height=&quot;91&quot; valign=&quot;top&quot;&gt;
&lt;table style=&quot;border-collapse: collapse&quot; width=&quot;&quot; class=&quot;tooltop&quot; height=&quot;76&quot;&gt;&lt;/p&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;table border=&quot;0&quot; style=&quot;border-collapse: collapse&quot; width=&quot;&quot; cellspacing=&quot;5&quot;&gt;
&lt;tr&gt;
&lt;td height=&quot;28&quot; width=&quot;100&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;b&gt;View source of&lt;/b&gt;&lt;/font&gt;&lt;b&gt;&lt;font size=&quot;2&quot;&gt;:
&lt;/font&gt;&lt;/b&gt;&lt;/td&gt;
&lt;td height=&quot;28&quot; width=&quot;&quot;&gt;
&lt;font size=&quot;1&quot;&gt;http://&lt;/font&gt;&lt;input type=&quot;text&quot; name=&quot;domain&quot; size=&quot;26&quot; value=&quot;&lt;?=$_POST['domain']?&gt;&quot;&gt;&lt;/td&gt;
&lt;td height=&quot;28&quot; width=&quot;&quot;&gt;
&lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;View!&quot; style=&quot;float: left&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td width=&quot;&quot; height=&quot;21&quot;&gt;&amp;nbsp;&lt;/td&gt;
&lt;td width=&quot;&quot; colspan=&quot;2&quot; height=&quot;21&quot; valign=&quot;top&quot;&gt;&lt;font size=&quot;1&quot;&gt;(eg. chapagain.com.np)&lt;/font&gt;&lt;/td&gt;&lt;/p&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;?php
if(isset($_POST['submit']))
{
?&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;textarea rows=&quot;10&quot; cols=&quot;60&quot; name=&quot;code&quot;&gt;&lt;?=$contents?&gt;&lt;/textarea&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;?php
}
?&gt;
&lt;/table&gt;
&lt;/form&gt;
&lt;script language=&quot;JavaScript&quot;&gt;
function validate(theform) {
if (theform.domain.value == &quot;&quot;) { alert(&quot;No Domain&quot;); return false; }
return true;
}
&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning /> <w:ValidateAgainstSchemas /> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:BreakWrappedTables /> <w:SnapToGridInCell /> <w:WrapTextWithPunct /> <w:UseAsianBreakRules /> <w:DontGrowAutofit /> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--> <!--[if gte mso 10]></p>
<style>
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:"Table Normal";
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-parent:"";
	mso-padding-alt:0in 5.4pt 0in 5.4pt;
	mso-para-margin:0in;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Times New Roman";
	mso-ansi-language:#0400;
	mso-fareast-language:#0400;
	mso-bidi-language:#0400;}
</style>
<p><![endif]--></p>
<p class="MsoNormal" style="text-align: justify;">
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small><img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=65&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/how-to-change-the-source-code-and-modifyparse-a-website/' rel='bookmark' title='Permanent Link: How to change the source code and modify/parse a website?'>How to change the source code and modify/parse a website?</a></li>
<li><a href='http://blog.chapagain.com.np/php-read-write-csv/' rel='bookmark' title='Permanent Link: PHP: Read Write CSV'>PHP: Read Write CSV</a></li>
<li><a href='http://blog.chapagain.com.np/php-source-code-encoding-with-ioncube-php-encoder/' rel='bookmark' title='Permanent Link: PHP source code encoding with ionCube PHP Encoder'>PHP source code encoding with ionCube PHP Encoder</a></li>
<li><a href='http://blog.chapagain.com.np/javascript-add-remove-html-elements/' rel='bookmark' title='Permanent Link: Javascript: Add Remove HTML elements'>Javascript: Add Remove HTML elements</a></li>
<li><a href='http://blog.chapagain.com.np/creating-dynamic-table-in-php/' rel='bookmark' title='Permanent Link: Creating dynamic table in PHP : Easy and Simple tutorial'>Creating dynamic table in PHP : Easy and Simple tutorial</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/how-to-get-html-source-code-of-a-website/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Generating random image</title>
		<link>http://blog.chapagain.com.np/generating-random-image/</link>
		<comments>http://blog.chapagain.com.np/generating-random-image/#comments</comments>
		<pubDate>Wed, 19 Mar 2008 11:20:08 +0000</pubDate>
		<dc:creator>Mukesh</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[random]]></category>

		<guid isPermaLink="false">http://blog.chapagain.com.np/2008/03/19/generating-random-image/</guid>
		<description><![CDATA[Generating/Displaying random image in PHP. Download code (images included):- Random image in PHP Enjoy PHPing !! Copyright &#169; 2011 This feed is for personal, non-commercial use only. The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement [...]


<strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/php-generating-random-string/' rel='bookmark' title='Permanent Link: PHP: Generating Multiple Random String'>PHP: Generating Multiple Random String</a></li>
<li><a href='http://blog.chapagain.com.np/random-number-string-generation-in-php/' rel='bookmark' title='Permanent Link: Random number, string generation in PHP'>Random number, string generation in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/jquery-grey-out-background-and-preview-image-as-popup/' rel='bookmark' title='Permanent Link: jQuery: Grey out background and preview image as popup'>jQuery: Grey out background and preview image as popup</a></li>
<li><a href='http://blog.chapagain.com.np/magento-set-random-order-in-collection-using-rand/' rel='bookmark' title='Permanent Link: Magento: Set Random Order in Collection using RAND()'>Magento: Set Random Order in Collection using RAND()</a></li>
<li><a href='http://blog.chapagain.com.np/phpthumb-the-best-php-thumbnail-image-generator/' rel='bookmark' title='Permanent Link: phpThumb(): The best PHP thumbnail image generator'>phpThumb(): The best PHP thumbnail image generator</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Generating/Displaying random image in PHP.</p>
<pre class="brush: php; title: ; notranslate">

&lt;?php
/*********************************

RANDOM IMAGE GENERATION

&lt;span id=&quot;more-45&quot;&gt;&lt;/span&gt;

*********************************/

//storing images in an array
$images = array(1 =&gt; &quot;mukesh1.jpg&quot;, 2 =&gt; &quot;mukesh2.jpg&quot;, 3 =&gt; &quot;mukesh4.jpg&quot;, 4 =&gt; &quot;mukesh6.jpg&quot;, 5 =&gt; &quot;mukesh9.jpg&quot;);

//printing the array
/*** print_r($images); ***/

//generating random number
//we have 5 elements in the array above
//so we will generate random number from 1 to 5
$num = rand(1,5);

//printing the images
echo &quot;Random Image Below: &quot;;
echo &quot;&lt;br/&gt;&quot;;
echo &quot;&lt;img src='&quot;.$images[$num].&quot;' alt='Random Image' title='Random Image'&gt;&quot;;

?&gt;
</pre>
<p>Download code (images included):-</p>
<p><a href="http://blog.chapagain.com.np/wp-content/uploads/2008/03/random.rar" title="Random image in PHP">Random image in PHP</a></p>
<p>Enjoy PHPing !!</p>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> )</small><img src="http://blog.chapagain.com.np/?ak_action=api_record_view&id=45&type=feed" alt="" />

<p><strong>Related posts:</strong><ol><li><a href='http://blog.chapagain.com.np/php-generating-random-string/' rel='bookmark' title='Permanent Link: PHP: Generating Multiple Random String'>PHP: Generating Multiple Random String</a></li>
<li><a href='http://blog.chapagain.com.np/random-number-string-generation-in-php/' rel='bookmark' title='Permanent Link: Random number, string generation in PHP'>Random number, string generation in PHP</a></li>
<li><a href='http://blog.chapagain.com.np/jquery-grey-out-background-and-preview-image-as-popup/' rel='bookmark' title='Permanent Link: jQuery: Grey out background and preview image as popup'>jQuery: Grey out background and preview image as popup</a></li>
<li><a href='http://blog.chapagain.com.np/magento-set-random-order-in-collection-using-rand/' rel='bookmark' title='Permanent Link: Magento: Set Random Order in Collection using RAND()'>Magento: Set Random Order in Collection using RAND()</a></li>
<li><a href='http://blog.chapagain.com.np/phpthumb-the-best-php-thumbnail-image-generator/' rel='bookmark' title='Permanent Link: phpThumb(): The best PHP thumbnail image generator'>phpThumb(): The best PHP thumbnail image generator</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.chapagain.com.np/generating-random-image/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
