<?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>OpenPeta &#187; Open Source Programming</title>
	<atom:link href="http://openpeta.com/index.php/category/open-source-programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://openpeta.com</link>
	<description>Open Mind ....  Open Source ...</description>
	<lastBuildDate>Wed, 21 Jul 2010 03:20: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>Sending Email Using PHP &#8211; Explained</title>
		<link>http://openpeta.com/index.php/2010/04/php-and-email-explained/</link>
		<comments>http://openpeta.com/index.php/2010/04/php-and-email-explained/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 10:51:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Open Source Programming]]></category>
		<category><![CDATA[Seamntic Web]]></category>

		<guid isPermaLink="false">http://www.openpeta.com/index.php/php-and-email-explained/</guid>
		<description><![CDATA[Plain Text and HTML Both plain text and HTML are used to convey email. Advantages of HTML include the ability to include inline links and images, set apart previous messages in block quotes, wrap naturally on any display, use emphasis such as underlines and italics, and change font styles. Sendmail Configuration in php.ini file # [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Plain Text and HTML</strong></p>
<blockquote><p>Both plain text and HTML are used to convey email. Advantages of HTML include the ability to include inline links and images, set apart previous messages in block quotes, wrap naturally on any display, use emphasis such as underlines and italics, and change font styles.</p></blockquote>
<p><strong>Sendmail Configuration in php.ini file</strong></p>
<blockquote><p><strong></strong><br />
# vim /opt/lampstack/php/etc/php.ini<br />
[mail function]<br />
; For Win32 only.<br />
SMTP = localhost<br />
smtp_port = 25<br />
; For Win32 only.<br />
sendmail_from = <a href="mailto:antony@gmail.com">antony@gmail.com</a><br />
; For Unix only. You may supply arguments as well (default: &#8220;sendmail –t -i&#8221;).<br />
sendmail_path = sendmain –t -i</p></blockquote>
<p><strong>Simple Example</strong></p>
<pre lang = "php" line="1">
&lt;php
$to = 'amalantonyraj@yahoo.co.in';
$subject = 'From PHP';
$message = 'Test';
if(mail($to, $subject, $message)) {
echo "Mail has been sent successfully";
}
else {
echo "Server error";
}
?&gt;
</pre>
<p><strong>Mail Function in PHP</strong></p>
<blockquote><p><strong></strong><br />
<em>Syntax</em><br />
bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )</p></blockquote>
<p><strong>Parameters</strong><br />
<strong><em>to </em></strong></p>
<p>Receiver, or receivers of the mail. The formatting of this string must comply with » RFC 2822. Some examples are:<br />
* user@example.com<br />
* user@example.com, anotheruser@example.com<br />
* User &lt;user@example.com&gt;<br />
* User &lt;user@example.com&gt;, Another User<br />
&lt;anotheruser@example.com&gt;<br />
<strong><em>subject<br />
</em></strong>Subject of the email to be sent.<br />
Caution<br />
This must not contain any newline characters, or the mail may not be sent properly.<br />
<strong><em>message</em></strong><br />
Message to be sent Each  line should be separated with a LF (\n). Lines should not be larger than 70 characters.</p>
<p><strong><em>additional_headers (optional)</em></strong><br />
String to be inserted at the end of the email header. This is typically used to add extra headers (From, Cc, and Bcc). Multiple extra headers should be separated with a CRLF (\r\n). <strong><em>additional_parameters (optional)</em></strong><br />
sending mail using the sendmail_path configuration setting. For example, this can be used to set the envelope sender address when using sendmail with the f sendmail option.</p>
<p>For  Emailing with attchment and extra headers . please refer this link</p>
<p><a title="http://pradeepkumar.org/2009/09/sending-email-in-php.html" href="http://pradeepkumar.org/2009/09/sending-email-in-php.html">http://pradeepkumar.org/2009/09/sending-email-in-php.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://openpeta.com/index.php/2010/04/php-and-email-explained/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Open Source Programming &#8211; Resources</title>
		<link>http://openpeta.com/index.php/2010/04/open-source-programming-resources/</link>
		<comments>http://openpeta.com/index.php/2010/04/open-source-programming-resources/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 10:19:57 +0000</pubDate>
		<dc:creator>ANTHONIRAJ</dc:creator>
				<category><![CDATA[Open Source Programming]]></category>
		<category><![CDATA[Softwares and EBooks]]></category>

		<guid isPermaLink="false">http://www.openpeta.com/?p=794</guid>
		<description><![CDATA[TEXT BOOKS [ Click on the links to download files] Open Source Web Development with LAMP Using Linux, Apache, MySQL Core Python Programming Practical Programming in TCl and TK Perl Programming REFERENCE BOOKS HTML BASICS Tag Basics Tag Reference W3C Html Tutorial Useful Html Tags JavaScript Reference PHP &#8211; MYSQL Emailing with PHP MySql CookBook [...]]]></description>
			<content:encoded><![CDATA[<p><strong>TEXT BOOKS [ Click on the links to download files]</strong></p>
<ol>
<li><a href="http://openpeta.com/wp-content/uploads/2010/04/mainbook1.zip" target="_blank">Open Source Web Development with LAMP Using Linux, Apache, MySQL</a></li>
<li><a href="http://www.openpeta.com/wp-content/uploads/2010/04/Core-Python-Programming.pdf" target="_blank">Core Python Programming</a></li>
<li><a href="http://openpeta.com/wp-content/uploads/2010/04/Practical-Programming-in-TCl-and-TK1.pdf" target="_blank">Practical Programming in TCl and TK</a></li>
<li><a href="http://openpeta.com/wp-content/uploads/2010/04/PerlIntroduction1.pdf" target="_blank">Perl Programming</a></li>
</ol>
<p><strong>REFERENCE BOOKS</strong></p>
<p><strong>HTML BASICS</strong></p>
<ol>
<li><a href="http://openpeta.com/wp-content/uploads/2010/04/HTML-Examples1.pdf" target="_blank">Tag Basics</a></li>
<li><a href="http://openpeta.com/wp-content/uploads/2010/04/HTML-TAG-REFERENCE1.pdf" target="_blank">Tag Reference</a></li>
<li><a href="http://openpeta.com/wp-content/uploads/2010/04/HTML-W3C-Tutorial1.pdf" target="_blank">W3C Html Tutorial</a></li>
<li><a href="http://openpeta.com/wp-content/uploads/2010/04/Useful-HTML-tags-and-their-attributes1.pdf" target="_blank">Useful Html Tags</a></li>
<li><a href="http://openpeta.com/wp-content/uploads/2010/04/JavaScript-Bible-5th-Edition-Quick-Reference1.pdf" target="_blank">JavaScript Reference</a></li>
</ol>
<p><strong>PHP &#8211; MYSQL</strong></p>
<ol>
<li><a href="http://openpeta.com/wp-content/uploads/2010/04/Emailing-with-PHP1.pdf" target="_blank">Emailing with PHP</a></li>
<li><a href="http://openpeta.com/wp-content/uploads/2010/04/MySql-CookBook1.pdf" target="_blank">MySql CookBook</a></li>
<li><a href="http://www.openpeta.com/wp-content/uploads/2010/04/Sams.zip" target="_blank">Sams Teach Yourself PHP, MySQL™ and Apache in 24 Hours</a></li>
<li><a href="http://openpeta.com/wp-content/uploads/2010/04/Web-Application-Developments-using-PHP-and-MYSQL1.zip" target="_blank">Web Application Developments using PHP and MYSQL</a></li>
<li><a href="http://openpeta.com/wp-content/uploads/2010/04/PHP-and-PostgreSQL1.pdf" target="_blank">PHP and PostgreSQL</a></li>
<li><a href="http://openpeta.com/wp-content/uploads/2010/04/PHP-Functions-Essential-Reference1.zip" target="_blank">PHP Functions Essential Reference</a></li>
</ol>
<p><strong>PYTHON AND TCL/TK</strong></p>
<ol>
<li><a href="http://openpeta.com/wp-content/uploads/2010/04/Learning-Python1.pdf" target="_blank">Learning Python</a></li>
<li><a href="http://openpeta.com/wp-content/uploads/2010/04/Python-2.5-Quick-Reference1.pdf" target="_blank">Python 2.5 Quick Reference</a></li>
<li><a href="http://openpeta.com/wp-content/uploads/2010/04/Tcl-and-the-Tk-Toolkit1.pdf" target="_blank">Tcl and the Tk Toolkit</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://openpeta.com/index.php/2010/04/open-source-programming-resources/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Eclipse or Netbeans ? Which one to Choose ?</title>
		<link>http://openpeta.com/index.php/2010/03/eclipse-or-netbeans-which-one-to-choose/</link>
		<comments>http://openpeta.com/index.php/2010/03/eclipse-or-netbeans-which-one-to-choose/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 02:29:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Open Source Programming]]></category>

		<guid isPermaLink="false">http://www.openpeta.com/index.php/eclipse-or-netbeans-which-one-to-choose/</guid>
		<description><![CDATA[This article is absolutely for beginners those who want to choose / learn best IDE for their project Development. Both IDE has lot of features and supporting major programming languages [ Java , C , C++ , PHP , HTML , Perl , Python , Ruby Etc .. ] . The Comparison of these IDE [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><span style="font-family: sans-serif;">This article is absolutely for beginners those who want to choose / learn best IDE for their project Development. Both IDE has lot of features and supporting major programming languages [ Java , C , C++ , PHP , HTML , Perl , Python , Ruby Etc .. ] . </span>The Comparison of these IDE are given here<br />
Eclipse IDE</p>
<div><img style="max-width: 800px;" title="Eclipse IDE" src="http://www.openpeta.com/wp-content/uploads/2010/03/Screenshot-Java-Sample-src-First.java-Eclipse-.png" alt="" width="546" height="339" /></div>
<p>Pros</p>
<ol>
<li>IDE Features [ Syntax Highlighting , Debugging , Preview ...]</li>
<li>Full Java , J2EE Development Support.</li>
<li>Various Flavors are available [Eclipse Classic , Eclipse for Java  , Eclipse for J2EE ... ]</li>
<li>Plug-in Development Support</li>
<li>Perl , Python , C , C++ , Ruby on Rails language support</li>
<li>Plug-in s are more [ You can find from Eclipse Plug-in Site ]</li>
<li>Execution Speed is good ,Memory Consumption is less, Eclipse will also work in 512 MB RAM ,</li>
<li>Debugging support for all languages.</li>
<li>Developer friendly</li>
</ol>
<p>Cons</p>
<ol>
<li>Single Bundle or package is not available for all features.</li>
<li>Lacks for Java Swing Designing</li>
<li>No Internal Server for running Client / Server Script like apache or tomcat or glassfish</li>
</ol>
<p>Netbeans IDE</p>
<div><img style="max-width: 800px;" src="http://openpeta.com/wp-content/uploads/2010/03/Screenshot-Sample-NetBeans-IDE-6.81.png" alt="" width="569" height="338" /></p>
<div>Pros</p>
<ol>
<li>All IDE Features</li>
<li>Java, C , C++ , PHP , Ruby , groovy languages support</li>
<li>Bundled with single package for all features</li>
<li>Various flavors are available [Netbeans Java , J2EE , C ..]</li>
<li>Debugging is good</li>
<li>WYSIWYG design for Java Swing Application</li>
<li>Full Java Script and CSS support</li>
<li>Tomcat and Glassfish serves are in built with Netbeans IDE</li>
<li>Developer friendly</li>
<li>Option for uploading project into open source community [ using Kenai]</li>
</ol>
<p>Cons</p>
<ol>
<li>Occupying More Memory (Min 512 MB)</li>
<li>Execution Speed is somewhat low comparing to eclipse [But its  based on processor and memory )</li>
<li>Plug-ins are less</li>
</ol>
<p>Final Words</p>
<blockquote><p>In my working experience with IDEs , If you want to develop Java Swing and J2EE Related Applications, you can move for Netbeans , or always choose Eclipse to code.</p></blockquote>
</div>
</div>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=b5aa4a13-a7f4-8413-8f6b-45ac24d43b7a" alt="" /></div>
]]></content:encoded>
			<wfw:commentRss>http://openpeta.com/index.php/2010/03/eclipse-or-netbeans-which-one-to-choose/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python Web Programming  Using Apache and mod-python</title>
		<link>http://openpeta.com/index.php/2010/02/python-web-programming-using-apache-and-mod-python/</link>
		<comments>http://openpeta.com/index.php/2010/02/python-web-programming-using-apache-and-mod-python/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 03:20:17 +0000</pubDate>
		<dc:creator>ANTHONIRAJ</dc:creator>
				<category><![CDATA[Open Source Programming]]></category>
		<category><![CDATA[Ubuntu Linux]]></category>

		<guid isPermaLink="false">http://www.openpeta.com/?p=602</guid>
		<description><![CDATA[Python client/server programming with Apache and mod-python in Ubuntu 9.10. 1. Goto Synaptic Package Manager and install the following packages a) apache2                                   [Apache Web Server] b) libapache2-mod-python      [Module for running Python Programs in Apache using mod-python ] c) mysql-server                          [Mysql Database Server] d) mysql-client                         [...]]]></description>
			<content:encoded><![CDATA[<p><strong> Python client/server programming with Apache and mod-python in Ubuntu 9.10.</strong></p>
<p>1. Goto Synaptic Package Manager and install the following packages</p>
<blockquote><p>a) apache2                                   [Apache Web Server]<br />
b) libapache2-mod-python      [Module for running Python Programs in Apache using mod-python ]<br />
c) mysql-server                          [Mysql Database Server]<br />
d) mysql-client                         [Mysql Client Terminal]<br />
e) pyhton-mysqldb                  [Pyhton and Mysql database programming fucntions ]<br />
f)  python3,1                             [optional but i strongly suggesting you to learn python 3.x ]</p></blockquote>
<p>2. After Installation You can start , stop, or restart the apache and mysql server using this commands</p>
<blockquote><p># sudo su<br />
# /etc/init.d/apache2 start/stop/restart<br />
# /etc/init.d/mysqld start/stop/restart</p></blockquote>
<p>3. If You want to create mysql database , use the given command</p>
<blockquote><p># mysql -u root -p</p></blockquote>
<p>[Type the password which  you had already given while installation of mysql server ]</p>
<p>4. Now Lets write one small web application  , Open Your favorite editor vim , gedit or Eclipse</p>
<blockquote><p># sudo su<br />
# vim first.py<br />
#!/usr/bin/python3.1<br />
print(&#8220;Content-Type: text/html\n&#8221;)<br />
print(&#8220;&lt;b&gt;My First Web Application in Python&lt;b&gt;&#8221;)</p></blockquote>
<p>Save and copy the file into</p>
<blockquote><p># cp first.py   /usr/lib/cgi-bin<br />
# chmod a+x /usr/bin/cgi-bin/first.py</p></blockquote>
<p>5. Now Open your web browser and type the address like</p>
<blockquote><p>http://localhost/cgi-bin/first.py</p></blockquote>
<p><a href="http://openpeta.com/wp-content/uploads/2010/02/Screenshot-Mozilla-Firefox1.png"><img class="aligncenter size-medium wp-image-605" title="Running Pyhton Web Application" src="http://www.openpeta.com/wp-content/uploads/2010/02/Screenshot-Mozilla-Firefox-300x153.png" alt="" width="300" height="153" /></a></p>
<p>Thats it &#8230; Enjoy the power of Python programming &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://openpeta.com/index.php/2010/02/python-web-programming-using-apache-and-mod-python/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>2D Graphics Using C in Linux [ Graphics.h in Linux ]</title>
		<link>http://openpeta.com/index.php/2009/09/2d-graphics-using-c-in-linux-graphics-h-in-linux/</link>
		<comments>http://openpeta.com/index.php/2009/09/2d-graphics-using-c-in-linux-graphics-h-in-linux/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 00:18:22 +0000</pubDate>
		<dc:creator>ANTHONIRAJ</dc:creator>
				<category><![CDATA[Image Processing]]></category>
		<category><![CDATA[Open Source Programming]]></category>
		<category><![CDATA[Ubuntu Linux]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.openpeta.com/?p=512</guid>
		<description><![CDATA[Most of technical people are trying to migrate from windows to Linux now a days , but they are facing lot of problems with Linux . they do not even know the forums and blogs of Linux which would be useful for finding answer to their query. The main problem of open source is choosing [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Most of technical people are trying to migrate from windows to Linux now a days , but they are facing lot of problems with Linux . they do not even know the forums and blogs of Linux which would be useful for finding answer to their query. The main problem of open source is choosing right one for user need. Because so many open source softwares are available for a single thing. Surely user need some supportive forum or website to find that one . open Peta is also doing that job. The idea of this  post coming to my mind from my college friend . One of my colleague asked me about computer graphics program in Linux using C programming language. the questions is</p>
<blockquote><p>How to draw line, circle , or 2D graphics in Linux Using C or C++?</p></blockquote>
<p>I was searching Internet and found some softwares for developing graphics applications in Linux. that softwares are listed here</p>
<ol>
<li>GTK+   &#8211; Gnome Tool Kit</li>
<li>QT  -  The X toolkit</li>
<li>SVGALIB   [ #include&lt;vgagl.h&gt; ]</li>
<li>libgraph [ #include&lt;graphics.h&gt; ]</li>
</ol>
<p style="text-align: justify;">GTK and QT are simple and used for high level Graphical User Interface [ GUI ] development. SVGALIB and libgraph is used for 2D graphics in Linux .  the syntax and functions are some what different for beginners  [specially the user from windows ] but most of users familiar with windows graphics.h header file in C and C++ , so we can move for libgraph which is exact one for windows graphics user . libgraph is an implementation of the Turbo C graphics API (graphics.h) on GNU/Linux using SDL [ Simple Direct Media Player ]. The library requires SDL for primitive graphics and SDL. First you need to install the following dependency packages using synaptic package manager in Ubuntu Linux to develop the graphics applications properly.</p>
<ul>
<li>SDL Library</li>
</ul>
<div id="attachment_516" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.openpeta.com/wp-content/uploads/2009/09/graph3.png"><img class="size-medium wp-image-516" title="Installing SDL Library" src="http://www.openpeta.com/wp-content/uploads/2009/09/graph3-300x187.png" alt="Installing SDL Library" width="300" height="187" /></a><p class="wp-caption-text">Installing SDL Library</p></div>
<ul>
<li>GUILE &#8211; GNU&#8217;s Ubiquitous Intelligent Language for Extension</li>
</ul>
<p style="text-align: justify;">
<div id="attachment_517" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.openpeta.com/wp-content/uploads/2009/09/graph5.png"><img class="size-medium wp-image-517" title="GUILE Installation" src="http://www.openpeta.com/wp-content/uploads/2009/09/graph5-300x187.png" alt="GUILE Installation" width="300" height="187" /></a><p class="wp-caption-text">GUILE Installation</p></div>
<ul>
<li> After installing these two packages , download the<a href="http://ftp.twaren.net/Unix/NonGNU/libgraph/" target="_blank"> libgraph</a> and install in your system</li>
</ul>
<blockquote><p>#sudo su</p>
<p>#tar -xzvf <a href="http://ftp.twaren.net/Unix/NonGNU/libgraph/libgraph-1.0.2.tar.gz">libgraph-1.0.2.tar.gz</a></p>
<p>#cd libgraph-1.0.2</p>
<p>#make</p>
<p># make install</p></blockquote>
<p>For better understanding , watch this video given here &#8230;.<br />
<center><object width="425" height="344" align="center"><param name="movie" value="http://www.youtube.com/v/hqYlnIn___E&#038;hl=en&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/hqYlnIn___E&#038;hl=en&#038;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></center><br />
Developing Graphics Application</p>
<p>1. Open your favorite text editor and type the following code</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &quot;stdio.h&quot;</span>
<span style="color: #339933;">#include &quot;graphics.h&quot;</span>
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #993333;">int</span> gd<span style="color: #339933;">=</span>DETECT<span style="color: #339933;">,</span> gm<span style="color: #339933;">=</span>VGAMAX<span style="color: #339933;">;</span>
initgraph<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>gd<span style="color: #339933;">,&amp;</span>amp<span style="color: #339933;">;</span>gm<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
moveto<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
setcolor<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
rectangle<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">50</span><span style="color: #339933;">,</span><span style="color: #0000dd;">50</span><span style="color: #339933;">,</span><span style="color: #0000dd;">500</span><span style="color: #339933;">,</span><span style="color: #0000dd;">200</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>kbhit<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
closegraph<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>2. Now compile the program with lgraph library</p>
<blockquote><p>#gcc line.c -lgraph -o output</p>
<p>#./output</p></blockquote>
<p>If you get any error in this line like</p>
<p>./output: error while loading shared libraries: libgraph.so.1: cannot open shared object file: No such file or directory</p>
<p>Do the following</p>
<blockquote><p>sudo cp /usr/local/lib/libgraph.* /usr/lib</p></blockquote>
<p>3. Now one new window will open , there you will get the output Rectangle in Red color.</p>
<div id="attachment_521" class="wp-caption aligncenter" style="width: 310px"><a href="http://openpeta.com/wp-content/uploads/2009/09/out2.png"><img class="size-medium wp-image-521" title="Output Window" src="http://www.openpeta.com/wp-content/uploads/2009/09/out-300x187.png" alt="Output Window" width="300" height="187" /></a><p class="wp-caption-text">Output Window</p></div>
<p>The advantage of libgraph is very easy to remember the syntax  [ all functions are same as turbo c graphics.h ] . still if you are facing any problem to develop graphics applications using this , send your problems through comment page of this post.</p>
]]></content:encoded>
			<wfw:commentRss>http://openpeta.com/index.php/2009/09/2d-graphics-using-c-in-linux-graphics-h-in-linux/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
		<item>
		<title>Everything About LAMP [Apache and MySQL] &#8211; III</title>
		<link>http://openpeta.com/index.php/2009/09/everything-about-lamp-apache-and-mysql-iii/</link>
		<comments>http://openpeta.com/index.php/2009/09/everything-about-lamp-apache-and-mysql-iii/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 12:06:44 +0000</pubDate>
		<dc:creator>ANTHONIRAJ</dc:creator>
				<category><![CDATA[Linux on NoteBook PCs]]></category>
		<category><![CDATA[Open Source Programming]]></category>
		<category><![CDATA[Ubuntu Linux]]></category>

		<guid isPermaLink="false">http://www.openpeta.com/?p=457</guid>
		<description><![CDATA[As we discussed in previous article , Apache is the core part of client server tecnlogies , all request and response are handled by apache in the form of HTML tags . Apache server was written in C language and its all functioning based on one configuration file [httpd.conf or apache2.conf ] which is located [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://www.openpeta.com/wp-content/uploads/2009/09/apache.png"><img class="alignnone size-full wp-image-458" title="Apache Logo" src="http://www.openpeta.com/wp-content/uploads/2009/09/apache.png" alt="Apache Logo" width="169" height="51" /></a>As we discussed in previous article , Apache is the core part of client server tecnlogies , all request and response are handled by apache in the form of HTML tags . Apache server was written in C language and its all functioning based on one configuration file [httpd.conf or apache2.conf ] which is located in apache root directory .  We can do some changes in this file like changing server and port name , virtual hosts etc .. Here the sample httpd.conf file</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Change this to Listen on specific IP addresses as shown below to</span>
<span style="color: #666666; font-style: italic;"># prevent Apache from glomming onto all bound IP addresses.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#Listen 12.34.56.78:80</span>
Listen <span style="color: #000000;">80</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Dynamic Shared Object (DSO) Support</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># To be able to use the functionality of a module which was built as a DSO you</span>
<span style="color: #666666; font-style: italic;"># have to place corresponding `LoadModule' lines at this location so the</span>
<span style="color: #666666; font-style: italic;"># directives contained in it are actually available _before_ they are used.</span>
<span style="color: #666666; font-style: italic;"># Statically compiled modules (those listed by `httpd -l') do not need</span>
<span style="color: #666666; font-style: italic;"># to be loaded here.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Example:</span>
<span style="color: #666666; font-style: italic;"># LoadModule foo_module modules/mod_foo.so</span>
<span style="color: #666666; font-style: italic;">#</span>
LoadModule authn_file_module modules<span style="color: #000000; font-weight: bold;">/</span>mod_authn_file.so</pre></div></div>

<p>The following sub sections contain a list of short descriptions for many of the directives included in<br />
httpd.conf:</p>
<p><strong>1. ServerRoot:</strong> – It specifies the top level directory containing website contents. By default, Server Root is set to “/etc/httpd” for both secure and non-secure servers. Example: ServerRoot “/etc/httpd”</p>
<p><strong>2. Timeout:</strong> – Defines in seconds the amount of time the server waits for receipts and transmissions during communications. (Default value is 300 seconds) Example: TimeOut 300</p>
<p><strong>3.KeepAlive :</strong>- It sets whether the server allows more than one request per connection and can be used to prevent any one client from consuming too much of server’s resources.(Default is off) Example: KeepAlive false</p>
<p><strong>4.MaxKeepAliveRequests:</strong> – Sets the maximum number of requests allowed per persistent connection. (Default is 100) Example: MaxKeepAliveRequests 100</p>
<p><strong>5. KeepAliveTimeout:</strong> – Sets the nuimber of seconds the server waits after a request has been served before it closes the connections. (Default is 15 seconds) Example: KeepAliveTimeout 15</p>
<p><strong>6. DocumentRoot:</strong> – Directory which contains most of the HTML files which are served in response to requests. (Default is “/var/www/html” directory) Example: DocumentRoot “/var/www/html”</p>
<p style="text-align: justify;">You can get more information about Apache from <a href="http://www.openpeta.com/index.php/apache-http-server/" target="_blank">http://www.openpeta.com/index.php/apache-http-server/</a><br />
and <a href="http://en.wikipedia.org/wiki/Apache_HTTP_Server" target="_blank">Wikipedia Page<br />
</a><br />
<a href="http://www.openpeta.com/wp-content/uploads/2009/09/489px-MySQL.svg.png"><img class="alignnone size-medium wp-image-462" title="MySQL Logo" src="http://www.openpeta.com/wp-content/uploads/2009/09/489px-MySQL.svg-300x155.png" alt="MySQL Logo" width="300" height="155" /></a> MySQL is the popular open source database which would be in back end of LAMP technology . If you want to store  huge information then you can move for this database otherwise you can use file for storing values. You can use command mode or phpmyadmin for creating database in MySQL. For command mode please refer this link <a href="http://www.openpeta.com/index.php/mysql-queries-explained/" target="_blank">http://www.openpeta.com/index.php/mysql-queries-explained/</a> or watch the following video for understanding phpmyadmin (Its a very good graphical interface for mysql to manipulate database)</p>
<p style="text-align: justify;">
<p><center><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/Qsv3X8pV9tQ&#038;hl=en&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Qsv3X8pV9tQ&#038;hl=en&#038;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></center></p>
]]></content:encoded>
			<wfw:commentRss>http://openpeta.com/index.php/2009/09/everything-about-lamp-apache-and-mysql-iii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Everything About LAMP [Linux, Apache,MySQL, PHP] – II</title>
		<link>http://openpeta.com/index.php/2009/09/everything-about-lamp-linux-apachemysql-php-%e2%80%93-ii/</link>
		<comments>http://openpeta.com/index.php/2009/09/everything-about-lamp-linux-apachemysql-php-%e2%80%93-ii/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 02:53:51 +0000</pubDate>
		<dc:creator>ANTHONIRAJ</dc:creator>
				<category><![CDATA[Linux on NoteBook PCs]]></category>
		<category><![CDATA[Open Source Programming]]></category>
		<category><![CDATA[Ubuntu Linux]]></category>

		<guid isPermaLink="false">http://www.openpeta.com/?p=393</guid>
		<description><![CDATA[You can develop Perl CGI application and PHP Web pages using LAMP . In this article lets discuss about how to develop these stuffs in easy ways [Installation of LAMP was explained in previous article]. This article is focused on Beginners and Intermediate users only . First we can move for developing PHP web application [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">You can develop Perl CGI application and PHP Web pages using LAMP . In this article lets discuss about how to develop these stuffs in easy ways [Installation of LAMP was explained in previous article]. This article is  focused on Beginners and Intermediate users only . First we can move for developing PHP web application , the things you need for doing this</p>
<ol>
<li>Text Editor [like Gedit in Linux or NotePad in Windows ]</li>
<li>LAMP Package</li>
<li>Web Browser [Firefox , Opera , Chrome ,IE]</li>
</ol>
<p style="text-align: justify;">You can develop PHP program using any text editor but i would strongly suggest you to use Netbeans IDE , its an open source and very powerful one , you can easily find documentation , on-line help and deployment everything within the IDE itself. I would like to explain this part taking simple PHP program.</p>
<p><strong>1. PHP Code for displaying Greeting message to user with current date [first.php]</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td 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;">/**
 *
 * Author: Anthoniraj Amalan
 * Created On Sep 4, 2009 8:15:39 AM
 * Version 1.0
 *
 */</span>
 <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Date: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;d/M/y&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;br /&gt;Welcome To Open Source World&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><strong>Explaination</strong></p>
<ol> Line 1 &amp; 11  : Starting and End tags which is used for identifying PHP Code.<br />
Line  2 to 8 : Multiline comment like c++ , You can describe anything related to your program<br />
Line 9 : echo() is the predefined function which is used for displaying given content in your web browser.date() is also predefined function for displaying current date [d - day , M - Month , y -Year ]<br />
 Line 10 : Just a Greeting Message , given inside the echo function</ol>
<p><strong>2. Running the Code</strong> After finishing our php code you need to copy file into apache htdocs folder . In our case , we have to copy the first.php to hdocs folder</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">  <span style="color: #666666; font-style: italic;">#sudo su</span>
  <span style="color: #666666; font-style: italic;">#chmod 777 /opt/lamp/apache2/htdocs</span>
  <span style="color: #666666; font-style: italic;">#chmod a+x first.php</span>
  <span style="color: #666666; font-style: italic;">#cp first.php /opt/lamp/apache2/htdocs</span></pre></td></tr></table></div>

<p><center><a href="http://openpeta.com/wp-content/uploads/2009/09/Screenshot1.png" align="center"><img class="alignnone size-medium wp-image-442" title="Neabeans IDE with PHP Development" src="http://www.openpeta.com/wp-content/uploads/2009/09/Screenshot-300x187.png" alt="Neabeans IDE with PHP Development" width="300" height="187" /></a></center><br />
<strong>Explaination</strong></p>
<ol> Line 1 : enter into root mode<br />
Line 2 : Assign all privileges [Read, Write, Execute ] to htdocs folder , then only you can save the php files into this folder<br />
Line 3 : Make the php file as executable one<br />
Line 4 : copy the first.php file into apcahe htdocs folder</ol>
<p><strong>Starting Apache Server</strong><br />
You need to start the server for running the php file or web page in your client system or browser. just do the following</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#sudo su</span>
<span style="color: #666666; font-style: italic;">#/opt/lamp/ctrlscript.sh start</span></pre></td></tr></table></div>

<p><center><a href="http://www.openpeta.com/wp-content/uploads/2009/09/starting-server.png" align="center"><img class="alignnone size-medium wp-image-443" title="Starting Server" src="http://www.openpeta.com/wp-content/uploads/2009/09/starting-server-300x187.png" alt="Starting Server" width="300" height="187" /></a></center><br />
<strong>3.Final Task</strong><br />
Now open your favorite web browser and type <strong>http://localhost/first.php</strong><em> in address bar , and your browser output will be like </em></p>
<blockquote>
<p style="text-align: justify;"><em>Date: 04/Sep/09<br />
Welcome To Open Source World</em></p></blockquote>
<p style="text-align: justify;"><em>If you want to run the php code in local area network or some other client which is connected to your server , then you need to change the address of the php page.instead of <strong>http://localhost/first.php</strong><em> , use your ip address like <strong>http://192.168.1.2/first.php</strong></em> in your client browser. [ To find Ip address of your server , use <strong>ifconfig </strong><em>command in terminal]</em></em></p>
]]></content:encoded>
			<wfw:commentRss>http://openpeta.com/index.php/2009/09/everything-about-lamp-linux-apachemysql-php-%e2%80%93-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GNU Octave &#8211; Scientific Computing Open Source Tools ( MATLAB compatiable software)</title>
		<link>http://openpeta.com/index.php/2008/07/gnu-octave-scientific-computing-open-source-tools-matlab-compatiable-software/</link>
		<comments>http://openpeta.com/index.php/2008/07/gnu-octave-scientific-computing-open-source-tools-matlab-compatiable-software/#comments</comments>
		<pubDate>Tue, 22 Jul 2008 01:42:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Octave]]></category>
		<category><![CDATA[Open Source Programming]]></category>

		<guid isPermaLink="false">http://www.openpeta.com/2008/07/22/gnu-octave-scientific-computing-open-source-tools-matlab-compatiable-software/</guid>
		<description><![CDATA[History The project was conceived around 1988. At first it was intended to be a companion to a chemical reactor design course. Real development was started by John W. Eaton in 1992. The first alpha release dates back to January 4, 1993 and on February 17, 1994 version 1.0 was released. Version 3.0 was released [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-weight: bold;">History</span>
<div style="text-align: justify;">The project was conceived around 1988. At first it was intended to be a companion to a chemical reactor design course. Real development was started by John W. Eaton in 1992. The first alpha release dates back to January 4, 1993 and on February 17, 1994 version 1.0 was released. Version 3.0 was released on December 21, 2007.</p>
<p>The name has nothing to do with musical octaves. Octave is the name of one of the early authors of Octave, a professor who was known for his ability to quickly come up with good approximations to numerical problems.</p>
<p><span style="font-weight: bold;">Download Details</span></p>
<p>You can download Ocatave from the following website<br />  http://www.gnu.org/software/octave/download.html</p>
<p><span style="font-weight: bold;">Technical details</span></p>
<p>    * Octave is written in C++ using STL libraries.<br />    * Octave has an interpreter that interprets the Octave language.<br />    * Octave itself is extensible using dynamically loadable modules.<br />    * Octave interpreter works in tandem with gnuplot and Grace software to create plots, graphs, and charts, and to save or print them.</p>
<p><span style="font-weight: bold;">Octave, the language</span></p>
<p>The Octave language is an interpreted programming language. It is a structured programming language (an example of which is the C language) and supports many common C standard library constructs, and can be extended to support UNIX system calls and functions. However, it does not support passing arguments by reference.</p>
<p>Octave programs consist of a list of function calls or script. The language is matrix-based and provides various functions for matrix operations. It is not object-oriented, but supports data structures.</p>
<p>Its syntax is very similar to MATLAB, and carefully programming a script will allow it to run on both Octave and MATLAB.</p>
<p>Because Octave is made available under the GNU General Public License, it may be freely copied and used. The program runs under most Unix and Unix-like operating systems, as well as Microsoft Windows.</p>
<p><span style="font-weight: bold;">MATLAB compatibility</span></p>
<p>Octave has been built with MATLAB compatibility in mind. It therefore shares many features with MATLAB:</p>
<p>   1. Matrices as fundamental data type.<br />   2. Built-in support for complex numbers.<br />   3. Powerful built-in math functions and extensive function libraries.<br />   4. Extensibility in the form of user-defined functions.</p>
<p>(Source : http://en.wikipedia.org/wiki/GNU_Octave)</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://openpeta.com/index.php/2008/07/gnu-octave-scientific-computing-open-source-tools-matlab-compatiable-software/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>File Handling in PHP</title>
		<link>http://openpeta.com/index.php/2008/03/file-handling-in-php/</link>
		<comments>http://openpeta.com/index.php/2008/03/file-handling-in-php/#comments</comments>
		<pubDate>Thu, 06 Mar 2008 09:03:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Open Source Programming]]></category>

		<guid isPermaLink="false">http://www.openpeta.com/2008/03/06/file-handling-in-php/</guid>
		<description><![CDATA[Functions Used in File Handling 1) fopen(filename,mode) &#8211; used for opening a file with specific mode.2) fclose(fp) &#8211; used to close the file. (fp -&#62; filepointer)3) feof(fp) &#8211; used to find the End of File4) fgetc(fp) &#8211; Gets character from file pointer5) fgets(fp) &#8211; Gets a line from file pointer6) fread(fp,size) &#8211; Binary-safe file read7) [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-weight: bold;">Functions Used in File Handling</span></p>
<p>1) fopen(filename,mode) &#8211; used for opening a file with specific mode.<br />2) fclose(fp)           &#8211; used to close the file. (fp -&gt; filepointer)<br />3) feof(fp)            &#8211; used to find the End of File<br />4) fgetc(fp)           &#8211; Gets character from file pointer<br />5) fgets(fp)           &#8211; Gets a line from file pointer<br />6) fread(fp,size)     &#8211; Binary-safe file read<br />7) fscanf(fp,format)    &#8211; Parses input from a file according to a format<br /> <img src='http://openpeta.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> fwrite(fp,string)    &#8211; Binary-safe file write<br />9) file_put_contents(fp,string)    &#8211; Write a string to a file<br />10) file_get_contents(fp)          &#8211; Reads entire file into a string<br />11) file(fp)                       &#8211; Reads entire file into an array<br />12) file_exists(fp)                &#8211; Checks whether a file or directory exists<br />13) is_readable(fp)                &#8211; Tells whether the filename is readable<br />14) is_writable(fp)                &#8211; Tells whether the filename is writable<br />15) is_file(path)                  &#8211; Tells whether the filename is a regular file<br />16) is_dir(path)                   &#8211; Tells whether the filename is a directory<br />17) is_link(path)                  &#8211; Tells whether the filename is a symbolic link<br />18) readlink(path)                 &#8211; Returns the target of a symbolic link<br />19) readdir                        &#8211; Read entry from directory handle<br />20) glob                           &#8211; Find pathnames matching a pattern<br />21) filesize(fp)                   &#8211; Gets file size<br />22) filetype(fp)                   &#8211; Gets file type<br />23) fprintf(fp,format)             &#8211; Write a formatted string to a stream<br />24) fstat(fp)                      &#8211; Gets information about a file using an open file pointer</p>
<p><span style="font-weight: bold;">File Opening Modes</span></p>
<p>      Modes       Description<br />   r     Read only. Starts at the beginning of the file<br />   r+     Read/Write. Starts at the beginning of the file<br />   w     Write only. Opens and clears the contents of file; or creates a new file if it doesn&#8217;t exist<br />   w+     Read/Write. Opens and clears the contents of file; or creates a new file if it doesn&#8217;t exist<br />   a     Append. Opens and writes to the end of the file or creates a new file if it doesn&#8217;t exist<br />   a+     Read/Append. Preserves file content by writing to the end of the file<br />   x     Write only. Creates a new file. Returns FALSE and an error if file already exists<br />   x+     Read/Write. Creates a new file. Returns FALSE and an error if file already exists</p>
<p><span style="font-weight: bold;">File Reading and Writing</span></p>
<p><span style="font-weight: bold;">Method 1 : File Reading Using Bytes</span></p>
<p>&lt;?php<br />/*<br />* Author : Antony<br />* Created on 22-Feb-08<br />* Program Name : filereadbytes.php<br />*/<br />$filename = &#8220;sample.txt&#8221;;<br />$fp = fopen($filename,&#8221;r&#8221;) or exit(&#8220;Unable to open file&#8230;&#8221;);<br />while(!feof($fp))<br />{<br />    $content =  fread($fp,filesize($fp));<br />    echo $content;<br /> }<br />fclose($fp);<br />?&gt;</p>
<p><span style="font-weight: bold;">Method 1 : File Reading Using Character</span></p>
<p>&lt;?php<br />/*<br />* Author : Antony<br />* Created on 22-Feb-08<br />* Program Name : fileread.php<br />*/<br />$filename = &#8220;/home/anthoniraj/textfiles/sample.txt&#8221;;<br />$fp = fopen($filename,&#8221;r&#8221;) or exit(&#8220;Unable to open file&#8230;&#8221;);<br />while(!feof($fp))<br />{<br />    echo fgetc($fp);<br />    echo &#8220;&lt;br /&gt;&#8221;;<br />}<br />fclose($fp);<br />?&gt;</p>
<p><span style="font-weight: bold;">Method 1 : File Reading Using Lines</span></p>
<p>&lt;?php<br />/*<br />* Author : Antony<br />* Created on 22-Feb-08<br />* Program Name : filereadline.php<br />*/<br />$filename = &#8220;sample.txt&#8221;;<br />$fp = fopen($filename,&#8221;r&#8221;) or exit(&#8220;Unable to open file&#8230;&#8221;);<br />while(!feof($fp))<br />{<br />    echo fgets($fp);<br />    echo &#8220;&lt;br /&gt;&#8221;;<br />}<br />fclose($fp);<br />?&gt;</p>
<p><span style="font-weight: bold;">Method 4: Writing Contents to File</span></p>
<p>&lt;?php<br />/*<br />* Author : Antony<br />* Created on 22-Feb-08<br />* Program Name : filewritechar.php<br />*/<br />  $filename = &#8220;sample.txt&#8221;;<br />  $fp = fopen($filename,&#8221;w&#8221;) or exit(&#8220;Unable to open file&#8230;&#8221;);<br />  $content = &#8220;Sample File Contents&#8221;;<br />  if(fwrite($fp,$content)==true)<br />  {<br />      echo &#8220;Successfully written&#8221;;<br />      }<br />      else<br />      {<br />          echo &#8220;Failed to write&#8221;;<br />      }</p>
<p>?&gt;</p>
<p><span style="font-weight: bold;">Simple Counter Program</span></p>
<p>&lt;?php<br />/*<br />* Author : Antony<br />* Created on 22-Feb-08<br />* Program Name : counter.php<br />*/<br />       $path = &#8220;counter.txt&#8221;;<br />   $fp = fopen($path, &#8220;r&#8221;);<br />   $count = fread($fp, 1024);<br />   fclose($fp);</p>
<p>   $count = $count + 1;<br />   echo &#8220;&lt;p&gt;Page views: &#8221; . $count . &#8220;&lt;/p&gt;&#8221;;</p>
<p>   $fp = fopen($path, &#8220;w&#8221;);<br />   fwrite($fp, $count);<br />   fclose($fp);</p>
<p>?&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://openpeta.com/index.php/2008/03/file-handling-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySql Insert Query With PHP Program</title>
		<link>http://openpeta.com/index.php/2008/02/mysql-insert-query-with-php-program/</link>
		<comments>http://openpeta.com/index.php/2008/02/mysql-insert-query-with-php-program/#comments</comments>
		<pubDate>Thu, 21 Feb 2008 11:50:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Open Source Programming]]></category>

		<guid isPermaLink="false">http://www.openpeta.com/2008/02/21/mysql-insert-query-with-php-program/</guid>
		<description><![CDATA[&#60;!DOCTYPE html PUBLIC &#8220;-//W3C//DTD XHTML 1.0 Transitional//EN&#8221; &#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#8221;&#62; &#60;html xmlns=&#8221;http://www.w3.org/1999/xhtml&#8221; lang=&#8221;en_US&#8221; xml:lang=&#8221;en_US&#8221;&#62;&#60;!&#8211; * Created on 05-Feb-08 * * To change the template for this generated file go to * Window &#8211; Preferences &#8211; PHPeclipse &#8211; PHP &#8211; Code Templates&#8211;&#62; &#60;head&#62; &#60;title&#62; Student Registration Form &#60;/title&#62; &#60;style type=&#8221;text/css&#8221;&#62; .text { color : #FFFFFF; font-family: Sans,TimesNewRoman; } [...]]]></description>
			<content:encoded><![CDATA[<p>&lt;!DOCTYPE html PUBLIC &#8220;-//W3C//DTD XHTML 1.0 Transitional//EN&#8221;<br />    &#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#8221;&gt;</p>
<p>&lt;html xmlns=&#8221;http://www.w3.org/1999/xhtml&#8221; lang=&#8221;en_US&#8221; xml:lang=&#8221;en_US&#8221;&gt;<br />&lt;!&#8211;<br /> * Created on 05-Feb-08<br /> *<br /> * To change the template for this generated file go to<br /> * Window &#8211; Preferences &#8211; PHPeclipse &#8211; PHP &#8211; Code Templates<br />&#8211;&gt;<br /> &lt;head&gt;<br />  &lt;title&gt; Student Registration Form  &lt;/title&gt;<br />  &lt;style type=&#8221;text/css&#8221;&gt;<br />   .text {<br />     color : #FFFFFF;<br />   font-family: Sans,TimesNewRoman;<br /> }</p>
<p>  &lt;/style&gt;<br /> &lt;/head&gt;<br /> &lt;body class=&#8221;text&#8221;&gt;<br /> &lt;form name=&#8221;insert&#8221; action=&#8221;MySqlInsert.php&#8221; method=&#8221;post&#8221;&gt;<br /> &lt;br /&gt;<br /> &lt;br/&gt;</p>
<p> &lt;table border =&#8221;0&#8243; align=&#8221;center&#8221; cellpadding=&#8221;17&#8243; bgcolor=&#8221;#49496E&#8221;&gt;<br />  &lt;tr&gt;<br />  &lt;td colspan=&#8221;2&#8243; align=&#8221;center&#8221;&gt;&lt;b&gt;Student Registration Form&lt;/b&gt;&lt;/td&gt;<br />  &lt;/tr&gt;<br />  &lt;tr&gt;<br />     &lt;td&gt;Student Name&lt;/td&gt;<br />     &lt;td&gt;&lt;input type =&#8221;text&#8221; name = &#8220;studentName&#8221; size =&#8221;20&#8243; /&gt; &lt;/td&gt;<br />  &lt;/tr&gt;<br />   &lt;tr&gt;<br />     &lt;td&gt;Date of Birth&lt;/td&gt;<br />     &lt;td&gt;<br />     &lt;select name =&#8221;day&#8221;&gt;<br />     &lt;option selected&gt;Day&lt;/option&gt;<br />     &lt;option value=&#8221;01&#8243;&gt;1&lt;/option&gt;<br />     &lt;option value=&#8221;02&#8243;&gt;2&lt;/option&gt;<br />     &lt;option value=&#8221;03&#8243;&gt;3&lt;/option&gt;<br />     &lt;option value=&#8221;04&#8243;&gt;4&lt;/option&gt;<br />     &lt;option value=&#8221;05&#8243;&gt;5&lt;/option&gt;<br />     &lt;option value=&#8221;06&#8243;&gt;6&lt;/option&gt;<br />     &lt;option value=&#8221;07&#8243;&gt;7&lt;/option&gt;<br />     &lt;option value=&#8221;08&#8243;&gt;8&lt;/option&gt;<br />     &lt;option value=&#8221;09&#8243;&gt;9&lt;/option&gt;<br />     &lt;option value=&#8221;10&#8243;&gt;10&lt;/option&gt;<br />     &lt;option value=&#8221;11&#8243;&gt;11&lt;/option&gt;<br />     &lt;option value=&#8221;12&#8243;&gt;12&lt;/option&gt;<br />     &lt;option value=&#8221;13&#8243;&gt;13&lt;/option&gt;<br />     &lt;option value=&#8221;14&#8243;&gt;14&lt;/option&gt;<br />     &lt;option value=&#8221;15&#8243;&gt;15&lt;/option&gt;<br />     &lt;option value=&#8221;16&#8243;&gt;16&lt;/option&gt;<br />     &lt;option value=&#8221;17&#8243;&gt;17&lt;/option&gt;<br />     &lt;option value=&#8221;18&#8243;&gt;18&lt;/option&gt;<br />     &lt;option value=&#8221;19&#8243;&gt;19&lt;/option&gt;<br />     &lt;option value=&#8221;20&#8243;&gt;20&lt;/option&gt;<br />     &lt;option value=&#8221;21&#8243;&gt;21&lt;/option&gt;<br />     &lt;option value=&#8221;22&#8243;&gt;22&lt;/option&gt;<br />     &lt;option value=&#8221;23&#8243;&gt;23&lt;/option&gt;<br />     &lt;option value=&#8221;24&#8243;&gt;24&lt;/option&gt;<br />     &lt;option value=&#8221;25&#8243;&gt;25&lt;/option&gt;<br />     &lt;option value=&#8221;26&#8243;&gt;26&lt;/option&gt;<br />     &lt;option value=&#8221;27&#8243;&gt;27&lt;/option&gt;<br />     &lt;option value=&#8221;28&#8243;&gt;28&lt;/option&gt;<br />     &lt;option value=&#8221;29&#8243;&gt;29&lt;/option&gt;<br />     &lt;option value=&#8221;30&#8243;&gt;30&lt;/option&gt;<br />     &lt;option value=&#8221;31&#8243;&gt;31&lt;/option&gt;<br />    &lt;/select&gt;<br />    &lt;select name =&#8221;month&#8221;&gt;<br />     &lt;option selected&gt;Month&lt;/option&gt;<br />     &lt;option value=&#8221;01&#8243;&gt;1&lt;/option&gt;<br />     &lt;option value=&#8221;02&#8243;&gt;2&lt;/option&gt;<br />     &lt;option value=&#8221;03&#8243;&gt;3&lt;/option&gt;<br />     &lt;option value=&#8221;04&#8243;&gt;4&lt;/option&gt;<br />     &lt;option value=&#8221;05&#8243;&gt;5&lt;/option&gt;<br />     &lt;option value=&#8221;06&#8243;&gt;6&lt;/option&gt;<br />     &lt;option value=&#8221;07&#8243;&gt;7&lt;/option&gt;<br />     &lt;option value=&#8221;08&#8243;&gt;8&lt;/option&gt;<br />     &lt;option value=&#8221;09&#8243;&gt;9&lt;/option&gt;<br />     &lt;option value=&#8221;10&#8243;&gt;10&lt;/option&gt;<br />     &lt;option value=&#8221;11&#8243;&gt;11&lt;/option&gt;<br />     &lt;option value=&#8221;12&#8243;&gt;12&lt;/option&gt;<br />     &lt;/select&gt;<br />    &lt;select name =&#8221;year&#8221;&gt;<br />     &lt;option selected&gt;Year&lt;/option&gt;<br />     &lt;option value=&#8221;1975&#8243;&gt;1975&lt;/option&gt;<br />     &lt;option value=&#8221;1976&#8243;&gt;1976&lt;/option&gt;<br />     &lt;option value=&#8221;1977&#8243;&gt;1977&lt;/option&gt;<br />     &lt;option value=&#8221;1978&#8243;&gt;1978&lt;/option&gt;<br />     &lt;option value=&#8221;1979&#8243;&gt;1979&lt;/option&gt;<br />     &lt;option value=&#8221;1980&#8243;&gt;1980&lt;/option&gt;<br />     &lt;option value=&#8221;1981&#8243;&gt;1981&lt;/option&gt;<br />     &lt;option value=&#8221;1982&#8243;&gt;1982&lt;/option&gt;<br />     &lt;option value=&#8221;1983&#8243;&gt;1983&lt;/option&gt;<br />     &lt;option value=&#8221;1984&#8243;&gt;1984&lt;/option&gt;<br />     &lt;option value=&#8221;1985&#8243;&gt;1985&lt;/option&gt;<br />     &lt;option value=&#8221;1986&#8243;&gt;1986&lt;/option&gt;<br />     &lt;option value=&#8221;1987&#8243;&gt;1987&lt;/option&gt;<br />     &lt;option value=&#8221;1988&#8243;&gt;1988&lt;/option&gt;<br />     &lt;option value=&#8221;1989&#8243;&gt;1989&lt;/option&gt;<br />     &lt;option value=&#8221;1990&#8243;&gt;1990&lt;/option&gt;<br />    &lt;/select&gt;<br />     &lt;/td&gt;<br />   &lt;/tr&gt;<br />   &lt;tr&gt;<br />     &lt;td&gt;Select the Course &lt;/td&gt;<br />     &lt;td&gt;<br />       &lt;select name =&#8221;course&#8221;&gt;<br />         &lt;option value =&#8221;mit&#8221;&gt; M.TECH-IT&lt;/option&gt;<br />         &lt;option value=&#8221;mcs&#8221;&gt; M.TECH -CS&lt;/option&gt;<br />         &lt;option value =&#8221;bit&#8221;&gt; B.TECH-IT&lt;/option&gt;<br />         &lt;option value=&#8221;bcs&#8221;&gt; B.TECH -CS&lt;/option&gt;<br />       &lt;/select&gt;<br />     &lt;/td&gt;<br />  &lt;/tr&gt;<br />   &lt;tr&gt;<br />     &lt;td&gt; Nationality&lt;/td&gt;<br />     &lt;td&gt;<br />        &lt;input type=&#8221;radio&#8221; name=&#8221;nation&#8221; value=&#8221;Indian&#8221; checked  /&gt; Indian &lt;br /&gt;<br />        &lt;input type=&#8221;radio&#8221; name=&#8221;nation&#8221; value=&#8221;Other&#8221; /&gt; Other<br />     &lt;/td&gt;<br />  &lt;/tr&gt;<br />   &lt;tr&gt;<br />     &lt;td&gt;DD Number&lt;/td&gt;<br />     &lt;td&gt;&lt;input type =&#8221;text&#8221; name = &#8220;ddNumber&#8221; size =&#8221;20&#8243; /&gt;&lt;/td&gt;<br />  &lt;/tr&gt;<br /> &lt;tr&gt;<br />  &lt;td colspan=&#8221;2&#8243; align=&#8221;center&#8221;&gt;&lt;input type=&#8221;submit&#8221; value=&#8221;Submit&#8221;/&gt; &lt;/td&gt;<br /> &lt;/tr&gt;<br /> &lt;/table&gt;<br />  &lt;/form&gt;<br /> &lt;/body&gt;<br />&lt;/html&gt;</p>
<p>PHP Program for Insertion<br />&lt;?php<br />/*<br /> * Author : Antony<br /> * Created on 05-Feb-08<br /> * Program Name : MySqlInsert.php<br /> */</p>
<p>  //initilaize the mysql user name and oassword<br />  $user=&#8221;root&#8221;;<br />  $password=&#8221;123456&#8243;;</p>
<p>  //database name<br />  $database=&#8221;studentinfo&#8221;;</p>
<p>  //get the information from Registration form<br />  $name = $_POST['studentName'];<br />  $dob = $_POST['year'].&#8221;-&#8221;.$_POST['month'].&#8221;-&#8221;.$_POST['day'];<br />  $course = $_POST['course'];<br />  $nationality = $_POST['nation'];<br />  $ddNumber=$_POST['ddNumber'];<br />  echo &#8220;$regId&lt;br /&gt;$name&lt;br/&gt;$dob&lt;br /&gt; $course&lt;br/&gt;$nationality&lt;br&gt;$ddNumber &lt;br&gt;&#8221;;<br />  //connect the mysql database<br />  $link=mysql_connect(localhost,$user,$password);<br />  @mysql_select_db($database) or die(&#8220;Unable to Open Databse&#8221;);</p>
<p>  //execute the query<br />  $sql =&#8221;INSERT INTO registration VALUES (&#8216;$name&#8217;,'$dob&#8217;,'$course&#8217;,'$nationality&#8217;,'$ddNumber&#8217;)&#8221;;<br />  $result = mysql_query($sql);</p>
<p>  if (!$result)<br />   {<br />    die(&#8216;Invalid query: &#8216; . mysql_error());<br />   }<br />  else<br />   {<br />    echo &#8220;Your Course has been registred successfully&#8221;;<br />   }<br />/* $num = mysql_affected_rows($result);<br />  echo $num;<br />  if($num!=0)<br />   {<br />    echo &#8220;Your Course has been registred successfully&#8221;;<br />    $regId++;<br />   }<br />   else<br />    {<br />     echo &#8220;Error in registration ,Please Try Later&#8221;;<br />    }<br />*/<br />  mysql_free_result($result);<br />  mysql_close($link);<br />?&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://openpeta.com/index.php/2008/02/mysql-insert-query-with-php-program/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
