<?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> &#187; PHP</title>
	<atom:link href="http://bipinb.com/category/php/feed" rel="self" type="application/rss+xml" />
	<link>http://bipinb.com</link>
	<description></description>
	<lastBuildDate>Tue, 10 Aug 2010 02:14:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using ORACLE and PHP in Ubuntu</title>
		<link>http://bipinb.com/using-oracle-and-php-in-ubuntu.htm</link>
		<comments>http://bipinb.com/using-oracle-and-php-in-ubuntu.htm#comments</comments>
		<pubDate>Fri, 04 Dec 2009 05:29:34 +0000</pubDate>
		<dc:creator>Bipin Balakrishnan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[php binding with oracle database]]></category>
		<category><![CDATA[php oracle API]]></category>
		<category><![CDATA[php with oracle]]></category>
		<category><![CDATA[php with oracle database]]></category>

		<guid isPermaLink="false">http://bipinb.com/?p=163</guid>
		<description><![CDATA[





Last week i got a chance to try ORACLE API, as i was a fresher in oracle at that time i was having little idea how to use it.After googling a while i got the way to use it.The steps i followed are written below in future hope this will find helpful for someone .
For [...]]]></description>
			<content:encoded><![CDATA[<!-- Easy AdSense V2.83 -->
<!-- Post[count: 3] -->
<div class="ezAdsense adsense adsense-leadin" style="text-align:center;margin:12px;"><script type="text/javascript"><!--
google_ad_client = "pub-8516280820391538";
/* 468x60, created 6/14/10 */
google_ad_slot = "2348800126";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><p><img class="aligncenter size-full wp-image-166" title="oracle-php" src="http://bipinb.com/wp-content/uploads/2009/12/oracle-php.jpg" alt="oracle-php" width="300" height="233" /></p>
<p>Last week i got a chance to try ORACLE API, as i was a fresher in oracle at that time i was having little idea how to use it.After googling a while i got the way to use it.The steps i followed are written below in future hope this will find helpful for someone .<br />
For setting up in local machine we need to install oracle Oracle Express Edition first. Please note my machine was , Ubuntu 9.04 and this worked for me.<br />
<strong>Installing  Oracle Express Edition</strong><br />
First you need to add this line to your /etc/apt/sources.lst</p>
<pre>deb http://oss.oracle.com/debian unstable main non-free</pre>
<p>Run</p>
<pre>sudo wget http://oss.oracle.com/el4/RPM-GPG-KEY-oracle -O- | apt-key add -
sudo apt-get update
sudo apt-get install oracle-xe</pre>
<p>Then run</p>
<pre>sudo /etc/init.d/oracle-xe configure</pre>
<p><strong>PHP-Oracle Binding</strong><br />
Now install PHP-oracle binding,  will get it from<a href="http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html"> here</a></p>
<p>Convert the rpm packages into debian packge using alien program if its not installed in your machine please install it using</p>
<pre>sudo apt-get install alien</pre>
<p>Run the commend in the downloaded packege folder</p>
<pre>sudo alien oracle*.rpm</pre>
<p>You’ll need the ‘pecl’ command, which is available in php-pear, php5-dev</p>
<pre>sudo apt-get install php-pear php5-dev
sudo pecl install oci8</pre>
<p>Enter 1 and check the oracle client lib path will be like this.</p>
<p>instantclient,/usr/lib/oracle/11.2/client/lib</p>
<p>Hit enter again and wait for a while.After completion add &#8220;extension=oci8.so&#8221; in your php.ini( both apache and cli) .Restart apache2 and check phpinfo();Okey our machine is ready to make calls to oracle binding functions and remote APIs.</p>
<p>The rest you can try out from <a href="http://wiki.oracle.com/page/PHP+Oracle+FAQ">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://bipinb.com/using-oracle-and-php-in-ubuntu.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Memcached with PHP</title>
		<link>http://bipinb.com/using-memcache-with-php.htm</link>
		<comments>http://bipinb.com/using-memcache-with-php.htm#comments</comments>
		<pubDate>Thu, 21 Aug 2008 06:29:58 +0000</pubDate>
		<dc:creator>Bipin Balakrishnan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Memcache]]></category>
		<category><![CDATA[Memcache configuration]]></category>
		<category><![CDATA[Memcache with PHP]]></category>
		<category><![CDATA[Memcached server Installing]]></category>

		<guid isPermaLink="false">http://bipinb.com/?p=86</guid>
		<description><![CDATA[    Memcache module provides handy procedural and object oriented interface    to memcached, highly effective caching daemon, which was especially    designed to decrease database load in dynamic web applications by caching the frequently accessed data.By default, memcached uses the port 11211.
Danga Interactive developed memcached to enhance the [...]]]></description>
			<content:encoded><![CDATA[<p>    Memcache module provides handy procedural and object oriented interface    to memcached, highly effective caching daemon, which was especially    designed to decrease database load in dynamic web applications by caching the frequently accessed data.By default, memcached uses the <a href="http://en.wikipedia.org/wiki/Computer_port_%28software%29" title="Computer port (software)">port</a> 11211.</p>
<p><a href="http://www.danga.com/" target="_blank">Danga Interactive</a> developed memcached to enhance the speed of  <a href="http://www.livejournal.com/" target="_blank">LiveJournal.com </a>, a site which was already doing 20 million+ dynamic page views per day for 1 million users with a bunch of webservers and a bunch of database servers. memcached dropped the database load to almost nothing, yielding faster page load times for users, better resource utilization, and faster access to the databases.</p>
<p>The system is used by several very large, well-known sites including <a href="http://en.wikipedia.org/wiki/YouTube" title="YouTube">YouTube</a>, <a href="http://en.wikipedia.org/wiki/LiveJournal" title="LiveJournal">LiveJournal</a>, <a href="http://en.wikipedia.org/wiki/Slashdot" title="Slashdot">Slashdot</a>, <a href="http://en.wikipedia.org/wiki/Wikipedia" title="Wikipedia">Wikipedia</a>, <a href="http://en.wikipedia.org/wiki/SourceForge" title="SourceForge" class="mw-redirect">SourceForge</a>, <a href="http://en.wikipedia.org/wiki/ShowClix" title="ShowClix">ShowClix</a>, <a href="http://en.wikipedia.org/wiki/GameFAQs" title="GameFAQs">GameFAQs</a>, <a href="http://en.wikipedia.org/wiki/Facebook" title="Facebook">Facebook</a>, <a href="http://en.wikipedia.org/wiki/Digg" title="Digg">Digg</a>, <a href="http://en.wikipedia.org/wiki/Twitter" title="Twitter">Twitter</a>, <a href="http://en.wikipedia.org/wiki/Fotolog" title="Fotolog">Fotolog</a>, <a href="http://en.wikipedia.org/wiki/BoardGameGeek" title="BoardGameGeek">BoardGameGeek</a>, <a href="http://en.wikipedia.org/wiki/NYTimes.com" title="NYTimes.com" class="mw-redirect">NYTimes.com</a>, <a href="http://en.wikipedia.org/wiki/DeviantART" title="DeviantART" class="mw-redirect">deviantART</a>, <a href="http://en.wikipedia.org/wiki/Jamendo" title="Jamendo">Jamendo</a>, <a href="http://en.wikipedia.org/wiki/Kayak.com" title="Kayak.com">Kayak</a> and in our<a href="http://mobshare.in"> Mobshare</a> too.</p>
<p><strong>Installing and Configuring Memcache</strong></p>
<pre>sudo apt-get install memcached
sudo apt-get install php5-memcache</pre>
<p>Configuration Files</p>
<p>edit  <strong>sudo vim /etc/php5/apache2/conf.d/memcache.ini</strong> or</p>
<p><strong>sudo</strong> <strong>vim /etc/php5/cli/conf.d/memcache.ini</strong> //for cli apps</p>
<pre>; uncomment the next line to enable the module
extension=memcache.so

[memcache]
memcache.dbpath="/var/lib/memcache"
memcache.maxreclevel=0
memcache.maxfiles=0
memcache.archivememlim=0
memcache.maxfilesize=0
memcache.maxratio=0</pre>
<p>Edit sudo vim /etc/memcached.conf to change the default configuration settings</p>
<p>Restart apache webserver</p>
<p>starting memcached</p>
<pre>sudo /etc/init.d/memcached start</pre>
<p>To see storing session on memcache on the terminal use</p>
<pre>sudo memcached -vv</pre>
<p>Eg 1: Using memcache in PHP</p>
<p>Testing Program whether it properly got installed and working fine</p>
<pre>&lt;?php
$memcache = new Memcache;
$memcache-&gt;connect('localhost', 11211) or die ("Could not connect");
$version = $memcache-&gt;getVersion();
echo "Server's version: ".$version."&lt;br/&gt;\n";
$tmp_object = new stdClass;
$tmp_object-&gt;str_attr = 'test';
$tmp_object-&gt;int_attr = 123;
$memcache-&gt;set('key', $tmp_object, false, 10) or die ("Failed to save data at the server");
echo "Store data in the cache (data will expire in 10 seconds)&lt;br/&gt;\n";
$get_result = $memcache-&gt;get('key');
echo "Data from the cache:&lt;br/&gt;\n";
var_dump($get_result);
?&gt;</pre>
<p>Outputs  this as result</p>
<pre>Server's version: 1.2.1&lt;br/&gt;
Store data in the cache (data will expire in 10 seconds)&lt;br/&gt;
Data from the cache:&lt;br/&gt;
object(stdClass)#3 (2) {
  ["str_attr"]=&gt;
  string(4) "test"
  ["int_attr"]=&gt;
  int(123)
}</pre>
<p>Example 2: Using in database access</p>
<pre>&lt;?php
$memcache = new Memcache;
$memcache-&gt;connect('localhost', 11211) or die ("Could not connect");
mysql_pconnect("localhost","root","");
mysql_select_db("bestofferIVR");
//Write your time consuming query here
$key = md5("SELECT * FROM callerinfo where cnumber='9941426932'");
$get_result = $memcache-&gt;get($key);
if ($get_result) {
print_r($get_result);
echo "If condition Working";
}
else {
 // Run the query and transform the result data into your final dataset form
 $qurey="SELECT * FROM callerinfo where cnumber='9941426932';";
 $result = mysql_query($qurey);
 $row = mysql_fetch_array($result);
 print_r($row);
 $memcache-&gt;set($key, $row, TRUE, 86400); // Store the result of the query for a day
 echo "Else condition Working";
}
?&gt;</pre>
<p>On the First Run the output will be as below, ie directly fetcing from the DB</p>
<pre>Array
(
    [0] =&gt; 5
    [id] =&gt; 5
    [1] =&gt; 9941426932
    [cnumber] =&gt; 9941426932
    [2] =&gt; 2008-03-20 08:28:57
    [time] =&gt; 2008-03-20 08:28:57
    [3] =&gt; mal12
    [scheme] =&gt; mal12
)
Else condition Working</pre>
<p>From the second run onwards the result will be as below ie using the memcache not DB</p>
<pre>Array
(
    [0] =&gt; 5
    [id] =&gt; 5
    [1] =&gt; 9941426932
    [cnumber] =&gt; 9946426932
    [2] =&gt; 2008-03-20 08:28:57
    [time] =&gt; 2008-03-20 08:28:57
    [3] =&gt; mal12
    [scheme] =&gt; mal12
)
If condition Working</pre>
]]></content:encoded>
			<wfw:commentRss>http://bipinb.com/using-memcache-with-php.htm/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>PHP command line agrument</title>
		<link>http://bipinb.com/php-command-line-agrument.htm</link>
		<comments>http://bipinb.com/php-command-line-agrument.htm#comments</comments>
		<pubDate>Thu, 24 Jul 2008 07:01:09 +0000</pubDate>
		<dc:creator>Bipin Balakrishnan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Command line argument PHP]]></category>
		<category><![CDATA[Passing  command line agrument in PHP]]></category>
		<category><![CDATA[PHP command line agrument]]></category>

		<guid isPermaLink="false">http://bipinb.com/?p=83</guid>
		<description><![CDATA[ 
We can pass command line argument to a PHP script as in any other programming language when we run it in the cli mode.For example make script called test.php in your editor.Copy paste content as follows.
&#60;?php
echo $argv[0];
echo $argv[1];
echo $argv[2];
?&#62;
Run the program as follows with command line argument as follows.
bipin@bipin-laptop:~/php$ php  test.php 10 22
Here [...]]]></description>
			<content:encoded><![CDATA[<p> <img src="http://bipinb.com/wp-content/uploads/2008/07/php.gif" alt="php.gif" /></p>
<p>We can pass command line argument to a PHP script as in any other programming language when we run it in the cli mode.For example make script called test.php in your editor.Copy paste content as follows.</p>
<pre>&lt;?php
echo $argv[0];
echo $argv[1];
echo $argv[2];
?&gt;</pre>
<p>Run the program as follows with command line argument as follows.</p>
<pre>bipin@bipin-laptop:~/php$ php  test.php 10 22</pre>
<p>Here the command line arguments are 10 and 22.The PHP script will take the argument as an array argv[] with the first element in the array (agrv[0]) as the program name and  the arguments passed being held after that.</p>
]]></content:encoded>
			<wfw:commentRss>http://bipinb.com/php-command-line-agrument.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making PHP program as Daemon</title>
		<link>http://bipinb.com/making-php-program-as-daemon.htm</link>
		<comments>http://bipinb.com/making-php-program-as-daemon.htm#comments</comments>
		<pubDate>Tue, 20 May 2008 16:35:50 +0000</pubDate>
		<dc:creator>Bipin Balakrishnan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Background Process with PHP]]></category>
		<category><![CDATA[PHP Daemon]]></category>

		<guid isPermaLink="false">http://bipinb.com/?p=68</guid>
		<description><![CDATA[It is some time necessary to make  a PHP progam as a daemon .Here it explains how it is possible.    Process Control support in PHP implements the Unix style of    process creation, program execution, signal handling and process    termination. Process Control should not be enabled [...]]]></description>
			<content:encoded><![CDATA[<p>It is some time necessary to make  a PHP progam as a <a href="http://en.wikipedia.org/wiki/Daemon_(computer_software)" target="_blank">daemon</a> .Here it explains how it is possible.    Process Control support in PHP implements the Unix style of    process creation, program execution, signal handling and process    termination. Process Control should not be enabled within a    web server environment and unexpected results may happen if any    Process Control functions are used within a web server environment.</p>
<p>The process control functions come along with the php-cli in linux.So we don&#8217;t need to install extra libraries for this to work.If php-cli is not there in your machine intall it with yum or apt-get.As i am using the ubuntu os im explaining with its command Ubuntu users can follow this.</p>
<pre>bipin@bipin-laptop:~$ sudo apt-get install php5-cli</pre>
<p>Copy and paste the code for background process</p>
<pre>&lt;?php
include_once('createdb.php');
declare(ticks=1);
$pid = pcntl_fork();
if ($pid == -1) {
die("could not fork");
} else if ($pid) {
exit(); // we are the parent
} else {
// we are the child
}
// detatch from the controlling terminal
if (posix_setsid() == -1) {
die("could not detach from terminal");
}
$posid=posix_getpid();
$fp = fopen("/var/run/process.pid", "w");
fwrite($fp, $posid);
fclose($fp);
// setup signal handlers
 pcntl_signal(SIGTERM, "sig_handler");
 pcntl_signal(SIGHUP, "sig_handler");
// loop forever performing tasks
 $dbobject = new DB();
 $dbobject-&gt;getCon();
 while (1) {
// do something interesting here, here i have called a function from other flile called "createdb.php"
$dbobject-&gt;CopyCallFiles();
}
 fclose($fp);
 function sig_handler($signo)
 {
switch ($signo) {
 case SIGTERM:
 // handle shutdown tasks
 exit;
 break;
 case SIGHUP:
 // handle restart tasks
 break;
 default:
 // handle all other signals
 }
}
?&gt;</pre>
<p>Run the program and the function $dbobject-&gt;CopyCallFiles(); will work as a deamon here we can include a file instead of the function also here.</p>
]]></content:encoded>
			<wfw:commentRss>http://bipinb.com/making-php-program-as-daemon.htm/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Converting WAV file to GSM file</title>
		<link>http://bipinb.com/converting-wav-file-to-gsm-file.htm</link>
		<comments>http://bipinb.com/converting-wav-file-to-gsm-file.htm#comments</comments>
		<pubDate>Fri, 14 Mar 2008 09:51:00 +0000</pubDate>
		<dc:creator>Bipin Balakrishnan</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://bipinb.com/?p=47</guid>
		<description><![CDATA[ 
Want to convert a sound file of type wav to gsm in your web application.You can use the code below.There are may desktop application softwares such as
switch,audacity which converts the sound format.Suppose we need in a web application in which we uploads the wav file and and it got converted into a gsm or [...]]]></description>
			<content:encoded><![CDATA[<p> <img src="http://bipinb.com/wp-content/uploads/2008/03/soundvisualizer.png" alt="soundvisualizer.png" height="303" width="512" /></p>
<p>Want to convert a sound file of type wav to gsm in your web application.You can use the code below.There are may desktop application softwares such as</p>
<p>switch,audacity which converts the sound format.Suppose we need in a web application in which we uploads the wav file and and it got converted into a gsm or any other format(depends on our need).</p>
<p>For me i need the wav file in gsm format as the output for some IVR application.</p>
<p>Before writing the code we need a opensource software called <a href="http://sox.sourceforge.net/">sox </a></p>
<p>to be installed in our system.Sox is a sound converter which converts sound from any format to any other sound format.</p>
<p>The rest is simple</p>
<p>copy and paste the code below</p>
<p>Uploading interface: HTML</p>
<p>Give some file name with extension Html or PHP</p>
<p>&lt;form enctype=&#8221;multipart/form-data&#8221; action=&#8221;uploader.php&#8221; method=&#8221;POST&#8221;&gt;<br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;MAX_FILE_SIZE&#8221; value=&#8221;10000000&#8243; /&gt;<br />
Choose a file to upload: &lt;input name=&#8221;uploadedfile&#8221; type=&#8221;file&#8221; /&gt;&lt;br /&gt;<br />
&lt;input type=&#8221;submit&#8221; value=&#8221;Upload File&#8221; /&gt;<br />
&lt;/form&gt;</p>
<p>Conversion program :</p>
<p>&lt;?php<br />
$target_path = &#8220;uploads/&#8221;;<br />
$file_name=basename( $_FILES['uploadedfile']['name']);<br />
$new = substr($file_name,0,-3).&#8221;gsm&#8221;;<br />
$cmd = &#8220;sox &#8220;.$file_name.&#8221; -r 8000 -c1 &#8220;.$new.&#8221; resample -ql&#8221;;<br />
exec($cmd);<br />
rename(&#8220;$new&#8221;, &#8220;uploads/$new&#8221;);<br />
?&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://bipinb.com/converting-wav-file-to-gsm-file.htm/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Call to undefined function mysql_connect()</title>
		<link>http://bipinb.com/call-to-undefined-function-mysql_connect.htm</link>
		<comments>http://bipinb.com/call-to-undefined-function-mysql_connect.htm#comments</comments>
		<pubDate>Thu, 21 Feb 2008 14:37:31 +0000</pubDate>
		<dc:creator>Bipin Balakrishnan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Call to undefined function mysql_connect() php]]></category>
		<category><![CDATA[MYSQL]]></category>

		<guid isPermaLink="false">http://bipinb.com/?p=33</guid>
		<description><![CDATA[Today i stucked an error when i was trying to run a php script in a server eventhough my server was php5-mysql installed on it.At first i checked php, it was installed and working fine.Then checked mySQL.It was also working fine.I got the mysql prompt and the query was also working fine.I was experiencing.Tried the [...]]]></description>
			<content:encoded><![CDATA[<p>Today i stucked an error when i was trying to run a php script in a server eventhough my server was php5-mysql installed on it.At first i checked php, it was installed and working fine.Then checked mySQL.It was also working fine.I got the mysql prompt and the query was also working fine.I was experiencing.Tried the same solution when i experienced first.But this time it did&#8217;nt got worked.This time i had to use other solution and it got worked.The problem is actually php.ini file have  enabled the mysql extension.</p>
<p>Solutions:</p>
<p>1)Remove php5-mysql with &#8220;apt-get remove php5-mysql&#8221; or &#8220;dpkg &#8211;purge remove php5-mysql and install it again or</p>
<p>2) Check your php.ini file to ensure it&#8217;s including the mysql.so library (extension=mysql.so) or</p>
<p>3)Type  &#8220;dpkg-reconfigure php5-mysql&#8221; (For ubuntu and debian users)</p>
<p>will prompt 2 screens like this.<a href="http://bipinb.com/wp-content/uploads/2008/02/2.jpg" title="2.jpg"><img src="http://bipinb.com/wp-content/uploads/2008/02/2.jpg" alt="2.jpg" /></a><a href="http://bipinb.com/wp-content/uploads/2008/02/11.jpeg" title="11.jpeg"><img src="http://bipinb.com/wp-content/uploads/2008/02/11.jpeg" alt="11.jpeg" /></a></p>
<p>Select &#8220;yes&#8221;  both and try again hope your problem will get resolved.</p>
<p>In my case it got resloved <img src='http://bipinb.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://bipinb.com/call-to-undefined-function-mysql_connect.htm/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP mysql database connection with OOPs</title>
		<link>http://bipinb.com/php-mysql-database-connection-with-oops.htm</link>
		<comments>http://bipinb.com/php-mysql-database-connection-with-oops.htm#comments</comments>
		<pubDate>Wed, 13 Feb 2008 08:21:56 +0000</pubDate>
		<dc:creator>Bipin Balakrishnan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP mysql database connection]]></category>

		<guid isPermaLink="false">http://bipinb.com/?p=12</guid>
		<description><![CDATA[create a class file first as this with file name createdb.php
&#60;?php
class DB
{
var $con;
function getCon()
{
$hostname=”localhost”;
$username=”root”;
$password=”&#8221;;
$con = mysql_connect($hostname,$username,$password);
if (!$con)
{
die(’Could not connect: ‘ . mysql_error());
}
mysql_select_db(”creditlimitIVR”, $con);
return $con;
}
?&#62;
Include this file “createdb.php” in your program where you want to connect the database create a class and call the function as follows in the “main.php”
&#60;?php
include_once(’createdb.php’);
$dbobject = new DB();
if (!$dbobject-&#62;getCon())
echo “Connection Failed”;
else
{
/* [...]]]></description>
			<content:encoded><![CDATA[<p class="post-content">create a class file first as this with file name createdb.php</p>
<p>&lt;?php<br />
class DB</p>
<p>{<br />
var $con;<br />
function getCon()<br />
{<br />
$hostname=”localhost”;<br />
$username=”root”;<br />
$password=”&#8221;;</p>
<p>$con = mysql_connect($hostname,$username,$password);<br />
if (!$con)<br />
{<br />
die(’Could not connect: ‘ . mysql_error());<br />
}<br />
mysql_select_db(”creditlimitIVR”, $con);<br />
return $con;</p>
<p>}<br />
?&gt;</p>
<p>Include this file “createdb.php” in your program where you want to connect the database create a class and call the function as follows in the “main.php”</p>
<p>&lt;?php<br />
include_once(’createdb.php’);<br />
$dbobject = new DB();<br />
if (!$dbobject-&gt;getCon())<br />
echo “Connection Failed”;<br />
else<br />
{<br />
/*    Do what you want */<br />
}</p>
<p>}</p>
<p>Similarly u can add more functions in createdb.php for inserting, deleteing, selecting etc. And can call from the program like</p>
<p>function InsertCallInfo($number)<br />
{</p>
<p>$date_time= date(’d-m-Y g:i a’);<br />
$sql=”INSERT INTO `callerinfo` (`number`, `time`, `status`) VALUES (’$number’, ‘$date_time’, ‘ATTEMPTED’)”;<br />
if (!mysql_query($sql))<br />
die(’Error: ‘ . mysql_error());<br />
}</p>
<p>I am calling it as $dbobject-&gt;InsertCallInfo($oneNo);<br />
in the main.php program.<br />
Add more and more functions and enjoy!!!!!</p>
]]></content:encoded>
			<wfw:commentRss>http://bipinb.com/php-mysql-database-connection-with-oops.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Web Service</title>
		<link>http://bipinb.com/web-service.htm</link>
		<comments>http://bipinb.com/web-service.htm#comments</comments>
		<pubDate>Wed, 13 Feb 2008 08:19:25 +0000</pubDate>
		<dc:creator>Bipin Balakrishnan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[nusoap]]></category>
		<category><![CDATA[Web Service]]></category>
		<category><![CDATA[Web service in php]]></category>

		<guid isPermaLink="false">http://bipinb.com/?p=11</guid>
		<description><![CDATA[A Web service (also Web Service) is defined by the W3C as “a software system designed to support interoperable Machine to Machine interaction over a network.” Web services are frequently just Web APIs that can be accessed over a network, such as the Internet, and executed on a remote system hosting the requested services.
The W3C [...]]]></description>
			<content:encoded><![CDATA[<p class="post-content">A Web service (also Web Service) is defined by the W3C as “a software system designed to support interoperable Machine to Machine interaction over a network.” Web services are frequently just Web APIs that can be accessed over a network, such as the Internet, and executed on a remote system hosting the requested services.</p>
<p>The W3C Web service definition encompasses many different systems, but in common usage the term refers to clients and servers that communicate using XML messages that follow the SOAP standard. Common in both the field and the terminology is the assumption that there is also a machine readable description of the operations supported by the server written in the Web Services Description Language (WSDL).Once we write a webservice and host it in a server we can call it from any language likewise a function call.</p>
<p>The below is simple example that demonstrate a webservice written in PHP using the library “nusoap”.To download nusoap <a href="http://dietrich.ganx4.com/nusoap/">Click Here!</a><br />
The client and server part here is written in PHP, you can use any language to to call the server functions.</p>
<p><strong>program discreption</strong>: The client will sent two strings to the server and server append a new string and returns to the clinet.</p>
<p><strong>copy and paste the code for the server</strong></p>
<p>&lt;?php</p>
<p>require_once(”nusoap/lib/nusoap.php”);</p>
<p>$server = new soap_server();</p>
<p>$server-&gt;configureWSDL(’Append’, ‘urn:Append’);</p>
<p>$server-&gt;register(’AppendString’,</p>
<p>array(’string_a’ =&gt;’xsd:string’,’string_b’ =&gt;’xsd:string’),</p>
<p>array(’return’=&gt;’xsd:string’),</p>
<p>‘urn:Append’,                    // namespace</p>
<p>‘urn:Append#AppendString’,  	// soapaction</p>
<p>‘rpc’,                               // style</p>
<p>‘encoded’,                           // use</p>
<p>‘Testing webservice’      // documentation</p>
<p>);</p>
<p>function AppendString($string_a, $string_b)</p>
<p>{</p>
<p>$server_msg=”I am the message from the server”;</p>
<p>$msg=$string_a.$string_b.$server_msg;</p>
<p>return $msg;</p>
<p>}</p>
<p>$server-&gt;service($HTTP_RAW_POST_DATA);</p>
<p>?&gt;</p>
<p>“http://localhost/server.php”<br />
will show the namespace</p>
<p><strong>copy and paste code for the client</strong></p>
<p>&lt;?php</p>
<p>require_once(”nusoap/lib/nusoap.php”);</p>
<p>$client=new soapclient1(’http://localhost/server.php?wsdl’, true);</p>
<p>$param=array(</p>
<p>’string_a’=&gt;’I am the first string from the client…’,</p>
<p>’string_b’=&gt;’and am the second string from the clinet….’,</p>
<p>);</p>
<p>$result =$client-&gt;call(’AppendString’, $param, ”, ”, false, true);</p>
<p>print_r ($result);</p>
<p>?&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://bipinb.com/web-service.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
