<?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>TECHiE TALKS &#187; PHP</title>
	<atom:link href="http://www.icpep.org/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.icpep.org</link>
	<description>Just another techie stuff</description>
	<lastBuildDate>Wed, 01 Feb 2012 23:59:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>Use Gmail Account To Relay Email From PHP mail Function</title>
		<link>http://www.icpep.org/use-gmail-account-to-relay-email-from-php-mail-function/</link>
		<comments>http://www.icpep.org/use-gmail-account-to-relay-email-from-php-mail-function/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 14:53:41 +0000</pubDate>
		<dc:creator>paparts</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Linux How To's]]></category>

		<guid isPermaLink="false">http://www.icpep.org/?p=1484</guid>
		<description><![CDATA[One of the things I find hard in developing a web application is using a library for sending email such as PHPMailer. I find it hard when used to send emails. Another thing I find hard is when sending emails in a localhost webserver. It would also cost me more and would take much time in setting up my own mail server. PHP&#8217;s mail function is also very useless in such testing ground. If you are using a gmail account [...]]]></description>
			<content:encoded><![CDATA[<p align="center"><img src="http://www.icpep.org/wp-content/uploads/2011/12/996862_internet_at_home_2.jpg" alt="Localhost Mail" title="Localhost Mail" width="300" height="300" class="aligncenter size-full wp-image-1485" /></p>
<p align="justify">One of the things I find hard in developing a web application is using a library for sending email such as PHPMailer.  I find it hard when used to send emails.  Another thing I find hard is when sending emails in a localhost webserver.  It would also cost me more and would take much time in setting up my own mail server.  PHP&#8217;s mail function is also very useless in such testing ground.</p>
<p align="justify">If you are using a gmail account and want to use PHP&#8217;s mail function in your local webserver, here is a better way to relay an email to gmail. I am using backtrack 5 Gnome and the steps will also work for debian based distros. Follow the steps below,</p>
<p>Install ssmtp,</p>
<div id="code">
$ sudo apt-get update &#038;&#038; apt-get install ssmtp
</div>
<p align="justify">After installing ssmtp, open the configuration file.</p>
<div id="code">$ sudo nano /etc/ssmtp/ssmtp.conf</div>
<p>Append the configuration at the bottom</p>
<div id="code">
AuthUser=icpep.org@gmail.com<br />
AuthPass=myPassword<br />
FromLineOverride=YES<br />
mailhub=smtp.gmail.com:587<br />
UseSTARTTLS=YES
</div>
<p>After the changes, you can now use PHP&#8217;s mail function</p>
<pre class="crayon-plain-tag"><code>&lt; ?php
$message = &quot;This is a test&quot;;
$message = wordwrap($message, 70);
mail('icpep.org@gmail.com', 'My Subject', $message);
?&gt;</code></pre>
<div id="seo_alrp_related"><h2>Posts Related to Use Gmail Account To Relay Email From PHP mail Function</h2><ul><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/4-thunderbird-add-ons/" rel="bookmark">4 Thunderbird Add-ons</a></h3><p>I am a great fan and a user of mozilla thunderbird. I have used different mail clients like microsoft outlook, opera mail, zimbra mail client, ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/phpmailer/" rel="bookmark">PHPMailer</a></h3><p>Sending E-Mail with PHP can be simple, or it can be very complex depending on what you want to do.  PHPmailer is a free PHP ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/pldts-port-25-smtp/" rel="bookmark">PLDT&#8217;s Port 25 (SMTP)</a></h3><p>Today, a friend and a colleague of mine called me and questioned me why she can't send emails using her mail client which is Incredimail ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/take-a-peek/" rel="bookmark">Peek Gadget</a></h3><p>What is the peek gadget?  Is it like just any ordinary gadgets?  Peek is the only gadget that is solely devoted to check emails.  Peek ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/thunderbird-to-outlook/" rel="bookmark">Thunderbird To Outlook</a></h3><p>I have successfully exported Thunderbird email files on ms outlook 2007 on a Windows XP platform which can also be done in windows vista and windows 7 platform. ...</p></div></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.icpep.org/use-gmail-account-to-relay-email-from-php-mail-function/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PDO Database Extensions Error</title>
		<link>http://www.icpep.org/pdo-database-extensions-error/</link>
		<comments>http://www.icpep.org/pdo-database-extensions-error/#comments</comments>
		<pubDate>Sat, 12 Nov 2011 10:45:19 +0000</pubDate>
		<dc:creator>paparts</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[php pdo mysql]]></category>

		<guid isPermaLink="false">http://www.icpep.org/?p=1415</guid>
		<description><![CDATA[&#160; &#160; I installed Apache, MySQL and PHP on windows 7.  I tried to install drupal version 7.9 and went through an error as shown in the image below: The error &#8220;Your web server does not appear to support any common PDO database extensions.&#8221; can be fixed by following these steps: Open your php.ini file Around line 966 uncomment the line &#8220;extension=php_pdo_mysql.dll&#8221; Make sure you have php_pdo_mysql.dll on your ext folder or download it here php_pdo_mysql Restart Apache and you can [...]]]></description>
			<content:encoded><![CDATA[<p align="center"><img class="size-full wp-image-1416 aligncenter" title="Drupal Logo" src="http://www.icpep.org/wp-content/uploads/2011/11/logo.png" alt="Drupal Logo" width="88" height="100" /></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>I installed Apache, MySQL and PHP on windows 7.  I tried to install drupal version 7.9 and went through an error as shown in the image below:</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-1417" title="drupal pdo error" src="http://www.icpep.org/wp-content/uploads/2011/11/drupal-pdo-error.jpg" alt="drupal pdo error" width="531" height="316" /></p>
<p style="text-align: justify;">The error &#8220;<em><span style="color: #ff0000;">Your web server does not appear to support any common PDO database extensions.</span></em>&#8221; can be fixed by following these steps:</p>
<ol>
<li>Open your <em>php.ini</em> file</li>
<li>Around line 966 uncomment the line &#8220;extension=php_pdo_mysql.dll&#8221;</li>
<li>Make sure you have php_pdo_mysql.dll on your ext folder or download it here <a class='wpdm-popup' rel='colorbox' title='php_pdo_mysql' href='http://www.icpep.org/?download=3' style="background:url('http://www.icpep.org/wp-content/plugins/download-manager/icon/download.png') no-repeat;padding:3px 12px 12px 28px;font:bold 10pt verdana;">php_pdo_mysql</a></li>
<li>Restart Apache and you can continue with the installation of drupal</li>
</ol>
<div id="seo_alrp_related"><h2>Posts Related to PDO Database Extensions Error</h2><ul><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/php-curl/" rel="bookmark">PHP Curl</a></h3><p>If you are a web developer and having problems on Installing PHP Curl on Apache with PHP installed on Windows Operating System, below is my ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/fixing-apaches-error-could-not-reliably-determine-the-servers-fully-qualified-domain-name-using-127-0-1-1-for-servername-in-ubuntu/" rel="bookmark">Fixing Apache&#8217;s Error: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName in Ubuntu</a></h3><p>One of the server I am using is running ubuntu. I am installing memcached on the server and every time I restart the web server ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/phpmyadmin-importing-large-data/" rel="bookmark">PHPMyAdmin Importing Large Data</a></h3><p>By Default phpmyadmin can import data on your mysql database up to 2MB of data and beyond that will be an error.  This has been ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/slackware-php-gd-error/" rel="bookmark">Slackware PHP GD Error</a></h3><p>In the past months I was able to handle a LAMP server, this is my second time to handle a UNIX based web server but ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/changing-the-owner-of-your-docroot-lamp/" rel="bookmark">Changing the Owner of Your Docroot (LAMP)</a></h3><p>In a LAMP server when you upload files in your htdocs folder by default  the owner of the files is root or the account you ...</p></div></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.icpep.org/pdo-database-extensions-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Curl</title>
		<link>http://www.icpep.org/php-curl/</link>
		<comments>http://www.icpep.org/php-curl/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 19:09:37 +0000</pubDate>
		<dc:creator>paparts</dc:creator>
				<category><![CDATA[Information]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.icpep.org/?p=922</guid>
		<description><![CDATA[If you are a web developer and having problems on Installing PHP Curl on Apache with PHP installed on Windows Operating System, below is my version of tonyspecer&#8217;s &#8220;cURL with PHP and Apache on Windows&#8220;.  The steps are simple and direct to the point. I have windows apache version 2.2.14 and PHP Version 5.2.10 installed on my Laptop using the installers provided on the respective sites. 1.  Install APACHE and PHP (I installed my APACHE on C:\apache and PHP on [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="size-full wp-image-923 aligncenter" title="PHP Curl" src="http://www.icpep.org/wp-content/uploads/2009/10/PHP-Curl.jpg" alt="PHP Curl" width="453" height="419" /></p>
<p>If you are a  web developer and having problems on Installing PHP Curl on Apache with PHP installed on Windows Operating System, below is my version of <a href="http://www.tonyspencer.com/2003/10/22/curl-with-php-and-apache-on-windows/">tonyspecer&#8217;s</a> &#8220;<strong>cURL with PHP and Apache on Windows</strong>&#8220;.  The steps are simple and direct to the point.</p>
<p>I have windows <a href="http://httpd.apache.org/">apache</a> version 2.2.14 and <a href="http://www.php.net/downloads.php">PHP</a> Version 5.2.10 installed on my Laptop using the installers provided on the respective sites.</p>
<p>1.  Install APACHE and PHP (<em>I installed my APACHE on C:\apache and PHP on C:\php directories</em> )<br />
2.  Edit the php.ini file found in the PHP directory.<span id="more-922"></span></p>
<ul>
<li>Near line  546 set the extension directory extension_dir = &#8220;C:\php\ext&#8221;.  In my case I have my extensions files inside the ext folder. You can use any folder name as long as you set it in the php.ini file.</li>
<li>Near line 472 set register_globals = On</li>
<li>Near line 630 set session.save_path=&#8221;C:\WINDOWS\Temp&#8221; or you can set any directory</li>
</ul>
<p>3.  On the PHP folder (<em>in my case C:\php\</em>) copy the php5ts.dll file to the bin folder of your Apache (<em>C:\apache\bin</em>\)<br />
4.  On the PHP folder (<em>C:\php\</em>) copy libeay32.dll and ssleay32.dll to &#8221; C:\WINDOWS\system32&#8243;  folder<br />
5.  Download CURL for Windows found at <a href="http://curl.haxx.se/download.html">http://curl.haxx.se/download.html</a> and put it on the PHP folder (C:\php\curl)<br />
6.  Download OpenSSL for Windows found at <a href="http://www.shininglightpro.com/products/Win32OpenSSL.html">http://www.shininglightpro.com/products/Win32OpenSSL.html</a>, for me I downloaded 7MB <span>OpenSSL v0.9.8k Installer<br />
</span></p>
<ul>
<li>To some Windows Visual c++ Redistributable is recommended before OpenSSL is installed.  The windows Visual c++ Redistributable can be downloaded at Microsoft website in the link:  <a href="http://www.microsoft.com/downloads/thankyou.aspx?familyId=9b2da534-3e03-4391-8a4d-074b9f2bc1bf&amp;displayLang=en">http://www.microsoft.com/downloads/thankyou.aspx?familyId=9b2da534-3e03-4391-8a4d-074b9f2bc1bf&amp;displayLang=en</a></li>
</ul>
<p>7.  Check to see if you have the following file: c:\windows\system32\msvcr70.dll. If not, search for it in Google and download it to system32.  If you can&#8217;t find it in that directory click this <a href="http://www.dll-files.com/dllindex/dll-files.shtml?msvcr70">link</a> to download the file from www.dllfiles.com.  Extract the zipped file and put it in the &#8220;c:\windows\system32\&#8221;  folder.<br />
8.  Uncomment the curl line in your php.ini file to enable curl:  extension=php_curl.dll but in my case I just added the line because it is not found in my php.ini file</p>
<p>9.  Edit the Apache httpd.conf file to enable php:</p>
<ul>
<li>For newer version of Apache add at the bottom
<ul>
<li>LoadModule php5_module &#8220;C:/php/php5apache2_2.dll&#8221;</li>
</ul>
</li>
<li>Then below add Line: AddType application/x-httpd-php .php</li>
</ul>
<p>10.  Restart Apache and your curl should be working now.</p>
<div id="seo_alrp_related"><h2>Posts Related to PHP Curl</h2><ul><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/install-and-enable-php5-curl-in-gnome-linux/" rel="bookmark">Install and Enable PHP5 cURL in Gnome-Linux</a></h3><p>PHP5 cURL &nbsp; If you already have a LAMP server and PHP cURL is not yet installed you can open the terminal and use the ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/pdo-database-extensions-error/" rel="bookmark">PDO Database Extensions Error</a></h3><p>&nbsp; &nbsp; I installed Apache, MySQL and PHP on windows 7.  I tried to install drupal version 7.9 and went through an error as shown ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/changing-the-owner-of-your-docroot-lamp/" rel="bookmark">Changing the Owner of Your Docroot (LAMP)</a></h3><p>In a LAMP server when you upload files in your htdocs folder by default  the owner of the files is root or the account you ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/apache-allow-htaccess/" rel="bookmark">Apache Allow htaccess</a></h3><p>Most web developers use a "third party" web server which comes in a package such as WAMP or XAMPP resulting to miss configuration of the ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/packet-tracer-on-ubuntu/" rel="bookmark">Packet Tracer on Ubuntu amd64 10.10</a></h3><p>Cisco's Packet Tracer is one of my most wanted application when I was using Windows.  When you login to your account in cisco you can ...</p></div></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.icpep.org/php-curl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHPMailer</title>
		<link>http://www.icpep.org/phpmailer/</link>
		<comments>http://www.icpep.org/phpmailer/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 19:47:01 +0000</pubDate>
		<dc:creator>paparts</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.icpep.org/?p=917</guid>
		<description><![CDATA[Sending E-Mail with PHP can be simple, or it can be very complex depending on what you want to do.  PHPmailer is a free PHP software used for sending emails or should I say used for &#8220;spamming&#8221;.  Though the software has been provided for free, many developers has gone beyond its real purpose.  With a block of IP Address , a web server with PHP installed in it is a perfect set-up for spamming. I have been using this free [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="size-full wp-image-918 aligncenter" title="PHPmailer" src="http://www.icpep.org/wp-content/uploads/2009/10/PHPmailer.jpg" alt="PHPmailer" width="403" height="302" /></p>
<p style="text-align: justify;">Sending E-Mail with PHP can be simple, or it can be very complex depending on what you want to do.  <a href="http://sourceforge.net/projects/phpmailer/">PHPmailer</a> is a free PHP software used for sending emails or should I say used for &#8220;spamming&#8221;.  Though the software has been provided for free, many developers has gone beyond its real purpose.  With a block of IP Address , a <a href="http://www.icpep.org/install-apache-tomcat/">web server</a> with PHP installed in it is a perfect set-up for spamming. I have been using this free PHP software  also and it has saved me a lot of work and headaches.</p>
<p style="text-align: justify;">What is in PHPmailer that makes it a good tool for sending emails? Does it only support a private host or is it capable of using gmail or any other public webmail services?<span id="more-917"></span></p>
<p style="text-align: justify;">PHPMailer is an <a href="http://www.icpep.org/object-oriented-php-samples">OOP PHP</a> script designed for sending emails.  Some of the &#8220;G&#8221; features of phpmailer are:</p>
<ul>
<li>Redundant SMTP servers.</li>
<li>Supports  8bit, base64, binary, and quoted-printable encoding.</li>
<li>Supports text and HTML type of email.</li>
<li>Can send emails with multiple TOs, CCs, BCCs and REPLY-TOs.</li>
<li>Capable of Word wrap.</li>
<li>Tested on multiple SMTP servers: Gmail, Sendmail, qmail, Postfix, Imail, Exchange, Mercury, Courier.</li>
<li>Works on any win32 or &#8220;nix&#8221; platforms.</li>
<li>Capable of handling and embedded image.</li>
<li>Capable of handling multiple attachments.</li>
<li>SMTP authentication.</li>
</ul>
<p>This are only few of the capabilities of a PHPMailer.  Above all the email handlers I used PHPmailer is number one on my list because of the ease of use.  It requires less skills with amazing performance, it is  a fully featured email transfer class for PHP.  Its indeed a thumbs up for the developers!</p>
<p style="text-align: justify;">
<div id="seo_alrp_related"><h2>Posts Related to PHPMailer</h2><ul><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/use-gmail-account-to-relay-email-from-php-mail-function/" rel="bookmark">Use Gmail Account To Relay Email From PHP mail Function</a></h3><p>One of the things I find hard in developing a web application is using a library for sending email such as PHPMailer. I find it ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/take-a-peek/" rel="bookmark">Peek Gadget</a></h3><p>What is the peek gadget?  Is it like just any ordinary gadgets?  Peek is the only gadget that is solely devoted to check emails.  Peek ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/pldts-port-25-smtp/" rel="bookmark">PLDT&#8217;s Port 25 (SMTP)</a></h3><p>Today, a friend and a colleague of mine called me and questioned me why she can't send emails using her mail client which is Incredimail ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/4-thunderbird-add-ons/" rel="bookmark">4 Thunderbird Add-ons</a></h3><p>I am a great fan and a user of mozilla thunderbird. I have used different mail clients like microsoft outlook, opera mail, zimbra mail client, ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/create-gmail-account-in-a-flash/" rel="bookmark">Create Gmail Account in a Flash</a></h3><p>With Jiffy GMail Email Creator Software you are able to better utilize the world’s best email service. For an unlimited amount of reasons, you might ...</p></div></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.icpep.org/phpmailer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Code Igniter Query</title>
		<link>http://www.icpep.org/code-igniter-query/</link>
		<comments>http://www.icpep.org/code-igniter-query/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 06:36:53 +0000</pubDate>
		<dc:creator>paparts</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.icpep.org/?p=869</guid>
		<description><![CDATA[Code Igniter is one of the best PHP framework available today.  It is free to download and user guide can be found together with the package. In Code Igniter the class that has the database queries or the methods that deals with getting the data on the database is placed inside the MODEL folder.  Just remember the &#8220;D&#8221; which tells us that Database methods are placed in this folder as what Jeffrey Way said in his tutorials. Here are different [...]]]></description>
			<content:encoded><![CDATA[<p align="center"><img src="http://www.icpep.org/wp-content/uploads/2009/10/php-code.jpg" alt="php code" title="php code" width="360" height="288" class="alignnone size-full wp-image-875" /></p>
<p><a href="http://www.icpep.org/code-igniter-installation-and-first-run/">Code Igniter</a> is one of the best PHP framework available today.  It is free to download and user guide can be found together with the package.</p>
<p>In Code Igniter the class that has the database queries or the methods that deals with getting the data on the database is placed inside the MODEL folder.  Just remember the &#8220;D&#8221; which tells us that Database methods are placed in this folder as what Jeffrey Way said in his tutorials.</p>
<p>Here are different Methods to query the database which is based in <a href="http://net.tutsplus.com">Nettuts+</a> tutorials.</p>
<p>Inside my Model folder I created a file Mydb.php, so the name of my class should be the same as the filename I created.<br />
<span id="more-869"></span></p><pre class="crayon-plain-tag"><code>&lt; ?php
class Mydb extends Model {

	function getData() {
		$this-&gt;db-&gt;select('title,content'); #where title and content are fields
		$sql = $this-&gt;db-&gt;get('data');  #data is a database table
		if($sql-&gt;num_rows() &gt; 0) {
			foreach($sql-&gt;result() as $row) {
				$data[] = $row;	
			}			
			return $data;
		} 	
        }

}

?&gt;</code></pre>
<p>In this method the line <em>$this->db->select(&#8216;title,content&#8217;);</em> is using code igniter &#8220;active records&#8221; where I stated the fields I need but if you want to get all the data just remove this line.  The line <em>$sql = $this->db->get(&#8216;data&#8217;);</em> tells the name of the table where I want to get the fields title and content.  To make sure I have something to work on the line <em>$sql->num_rows() > 0</em> is placed and the data is placed inside the array $data[].</p>
<p>To be more specific in using code igniter active records,</p>
<pre class="crayon-plain-tag"><code>&lt; ?php
class Mydb extends Model {

	function getData() {
		$this-&gt;db-&gt;select('title,content'); 
		$this-&gt;db-&gt;from('data');
		$this-&gt;db-&gt;where('id',1); 
		$sql = $this-&gt;db-&gt;get();  
		if($sql-&gt;num_rows() &gt; 0) {
			foreach($sql-&gt;result() as $row) {
				$data[] = $row;	
			}			
			return $data;
		} 	
        }
}

?&gt;</code></pre><p><p>Another way of querying is:</p><pre class="crayon-plain-tag"><code>&lt; ?php

class Mydb extends Model {

	function getData() {
		$sql = $this-&gt;db-&gt;query('SELECT * FROM data');
		if($sql-&gt;num_rows() &gt; 0) {
			foreach($sql-&gt;result() as $row) {
				$data[] = $row;	
			}			
			return $data;
		} 	
	}

}

?&gt;</code></pre><p><p>
<p>The line<em> $sql = $this->db->query(&#8216;SELECT * FROM data&#8217;);</em> is simply putting the query inside the predefined method in Code Igniter $this->db->query(&#8216;[query]&#8216;).  Still the data returned is an array.</p>
<p>To query with a user input,</p>
<pre class="crayon-plain-tag"><code>&lt; ?php

class Mydb extends Model {

	function getData() {
		$sql = &quot;select * from data where id=?&quot;;
		$val = $this-&gt;db-&gt;query($sql, 2);
		if($val-&gt;num_rows() &gt; 0) {
			foreach($val-&gt;result() as $row) {
				$data[] = $row;	
			}			
			return $data;
		} 	
	}

}

?&gt;</code></pre><p><p><p>
<p>The line <em>$sql = &#8220;select * from data where id=?&#8221;;</em> is our database query where ? is any value passed to it.  The line <em>$val = $this->db->query($sql, 2);</em> is where we execute our query and the value passed to &#8220;?&#8221; is 2. But what if we have more than 1 condition in our query,</p><pre class="crayon-plain-tag"><code>&lt; ?php

class Mydb extends Model {

	function getData() {
		$sql = &quot;select * from data where id=? and author = ?&quot;;
		$val = $this-&gt;db-&gt;query($sql, array(1, 'Allan'));
		if($val-&gt;num_rows() &gt; 0) {
			foreach($val-&gt;result() as $row) {
				$data[] = $row;	
			}			
			return $data;
		} 	
	}

}

?&gt;</code></pre><p><p><p><p>
<p>If we have more than one condition in our query we just use an array stating the value for our conditions.</p>
<div id="seo_alrp_related"><h2>Posts Related to Code Igniter Query</h2><ul><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/mysql-duplicate-error/" rel="bookmark">Mysql Duplicate Error</a></h3><p>I created a web application that managers collected links.  The web application was called duplicate checker where premium links collected are being stored in a ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/phpmyadmin-importing-large-data/" rel="bookmark">PHPMyAdmin Importing Large Data</a></h3><p>By Default phpmyadmin can import data on your mysql database up to 2MB of data and beyond that will be an error.  This has been ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/code-igniter-installation-and-first-run/" rel="bookmark">Code Igniter Installation and First Run</a></h3><p>Code Igniter is an PHP Application Development Framework - a toolkit for PHP developers. The main goal of Code Igniter is to enable developers to ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/setting-up-a-memcached-server/" rel="bookmark">Setting Up a MemCached Server</a></h3><p>image from www.memcached.org Based on their official website memcached is defined as: Free & open source, high-performance, distributed memory object caching system, generic in nature, ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/change-a-string-or-character-in-mysql/" rel="bookmark">Change a String or Character in MySQL</a></h3><p>Knowing the right MySQL statement is the most important part in having thousands of data in your database, one false move and you can't undo ...</p></div></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.icpep.org/code-igniter-query/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Session Authentication</title>
		<link>http://www.icpep.org/session-authentication/</link>
		<comments>http://www.icpep.org/session-authentication/#comments</comments>
		<pubDate>Wed, 20 May 2009 12:25:56 +0000</pubDate>
		<dc:creator>paparts</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.icpep.org/?p=609</guid>
		<description><![CDATA[One problem in creating a PHP Session Authentication is that when you are logged in and suddenly logs out and click the back button you will be returned to the page where you kast visited.   Isn&#8217;t this a problem especially when you have important data in that page.  So if you have problem with this let me share a code that will surely eleminate the problem.  In this code there is no need for javascripts to disable the back button(what [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="size-full wp-image-610 aligncenter" title="phpsession" src="http://www.icpep.org/wp-content/uploads/2009/05/phpsession.jpg" alt="phpsession" width="446" height="210" /></p>
<p style="text-align: justify;">One problem in creating a PHP Session Authentication is that when you are logged in and suddenly logs out and click the back button you will be returned to the page where you kast visited.   Isn&#8217;t this a problem especially when you have important data in that page.  So if you have problem with this let me share a code that will surely eleminate the problem.  In this code there is no need for javascripts to disable the back button(what if js is disabled on the browser?).</p>
<p style="text-align: justify;">The code uses session and when the user logs out the user is redirected to the login page and when he clicks the back button it will redirect back to the login page.  This is one trick for PHP Security Authentication.</p>
<p style="text-align: center;"><p></p><pre class="crayon-plain-tag"><code>#create a function to redirect the user to login page
#this should be on your php functions
function redirect($url){
	echo &quot;&amp;lt;script type='text/javascript'&amp;gt;&quot;; 
	echo &quot;window.location.href='$url'&quot;;
	echo &quot;&amp;lt;/script&amp;gt;&quot;; 
}

#this should be in your page where you authenticate the user
session_start();
$sql = mysql_query(&quot;select * from user
       where username=\&quot;$username\&quot; and userpassword=\&quot;$password\&quot;&quot;);

if(mysql_num_rows($sql) &amp;gt; 0) {
 $_SESSION['auth'] = true;
} else{
  redirect('login.php');
}

#so on the logout file there should be
session_destroy();
redirect('login.php');</code></pre>
<p align="justify"><span id="more-609"></span>Before starting in any of your PHP file you need to put this codes so that every now and the session is well monitored.</p>
<pre class="crayon-plain-tag"><code>if( $_SESSION['auth'] == true) {

#PHP code here ...

} else{

redirect('login.php');
}</code></pre><p>
<p style="text-align: justify;">So in this code if the session is not true the user is redirected to the login page.  So when the user press that back button the user is always redirected to login page because the session created was destroyed.  I hope this code will help a lot especially those who just started their PHP programming.</p>
<div id="seo_alrp_related"><h2>Posts Related to Session Authentication</h2><ul><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/black-hat-seo/" rel="bookmark">black hat Search Engine Optimization</a></h3><p>These black hat SEO techniques usually include one or more of the following characteristics: 1. One who breaks search engine rules. 2. Unethically presents content ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/backtrack-5-bug-fix/" rel="bookmark">Backtrack 5 Bug Fix</a></h3><p>I switched my ubuntu Oneiric to bactrack 5 Gnome and try out the new tools I wanted to use. Lately I thought everything will be ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/code-igniter-query/" rel="bookmark">Code Igniter Query</a></h3><p>Code Igniter is one of the best PHP framework available today.  It is free to download and user guide can be found together with the ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/top-10-benifits-of-standards-based-programming/" rel="bookmark">TOP 10 Benefits of Standards-based Programming</a></h3><p>1. Deliver to multiple user agents. The same piece of marked-up content is readily deliverable in a wide variety of user agents, the collective name ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/telepornnet-redirect/" rel="bookmark">Teleporn.net Redirect</a></h3><p>In the past few days I was solving a problem on a site and the problem was this; The site has an iframe virus, the ...</p></div></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.icpep.org/session-authentication/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP Displaying On the Browser</title>
		<link>http://www.icpep.org/php-displaying-on-the-browser/</link>
		<comments>http://www.icpep.org/php-displaying-on-the-browser/#comments</comments>
		<pubDate>Sat, 02 May 2009 02:32:57 +0000</pubDate>
		<dc:creator>paparts</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.icpep.org/?p=533</guid>
		<description><![CDATA[When its your first time to code HTML , the tendency of opening the file is by clicking it twice and yes the expected result is displaying.  And from that point on, they can view their web page/website as it was intended to be viewed.  Above image is one example of an HTML file viewed by double clicking on the file. But when you have a web server things are different. Last night I have this friend who was programming [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><img class="aligncenter size-full wp-image-536" title="html" src="http://www.icpep.org/wp-content/uploads/2009/05/html.jpg" alt="html" width="569" height="50" /></p>
<p style="text-align: justify;">When its your first time to code HTML , the tendency of opening the file is by clicking it twice and yes the expected result is displaying.   And from that point on, they can view their web page/website as it was intended to be viewed.  Above image is one example of an HTML file viewed by double clicking on the file. But when you have a web server things are different.</p>
<p style="text-align: justify;">Last night I have this friend who was programming a system using PHP and she was asking me why all the PHP codes are displaying on the browser.  I was thinking that the host or PHP was down and it bothered me a lot since there are also other developers  and other clients using the web server and this would be a bigger delay on the business.   It was relieved with what I saw because the problem was what she entered on the browser.<span id="more-533"></span></p>
<p style="text-align: justify;"><img class="aligncenter size-full wp-image-537" title="wrong-php1" src="http://www.icpep.org/wp-content/uploads/2009/05/wrong-php1.jpg" alt="wrong-php1" width="519" height="78" /></p>
<p style="text-align: justify;">This is one problem in opening a PHP file.  You shold use the name of your server or IP then the PHP file name like http://127.0.0.1/fortest.php or if you are using localhost then that would be http://localhost/fortest.php.  If you are using your domain that is being hosted by a certain web hosting<a href="http://webhostingrating.com/"> </a>company then you can use http://www.mydomainname.com/fortest.php.  But if after putting the domain name and the PHP codes are displayed one possible problem would be the PHP is down.</p>
<p style="text-align: justify;">If you are having troubles where to find the best Web hosting company then better look for a site that does <a href="http://webhostingrating.com/">web hosting rating</a> this would surely help you in finding the best web hosting company for your business.There you can see the top rated web hosting company that has been serving the net for years.</p>
<div id="seo_alrp_related"><h2>Posts Related to PHP Displaying On the Browser </h2><ul><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/internet-web-hosting/" rel="bookmark">Internet Web Hosting</a></h3><p>There are millions of resources over the net to search whom to rely your web sites.  There are also needed options that you must consider ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/fixing-apaches-error-could-not-reliably-determine-the-servers-fully-qualified-domain-name-using-127-0-1-1-for-servername-in-ubuntu/" rel="bookmark">Fixing Apache&#8217;s Error: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName in Ubuntu</a></h3><p>One of the server I am using is running ubuntu. I am installing memcached on the server and every time I restart the web server ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/blogs-on-the-net/" rel="bookmark">Make Money Blogging</a></h3><p>What is a blog in the first place?  My friends keep on asking me what a blog is and I think now is the best ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/html-conceptualized/" rel="bookmark">Easiest HTML Conceptualized</a></h3><p>HTML files consist of ordinary text with the addition of what are called tags. Tags, which represent the markup of the text, are special codes ...</p></div></li><li><div class="seo_alrp_rl_content"><h3><a href="http://www.icpep.org/getting-main-domain/" rel="bookmark">Getting Main Domain</a></h3><p>Do you want to extract the main domain of a URL?  Here is a function that works well and can be modified easily.  I found ...</p></div></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.icpep.org/php-displaying-on-the-browser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

