<?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>Breathing Spring &#187; php</title>
	<atom:link href="http://breathing-spring.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://breathing-spring.com</link>
	<description></description>
	<lastBuildDate>Tue, 29 Jun 2010 07:48:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Starting with SQLITE WITH PHP</title>
		<link>http://breathing-spring.com/starting-with-sqlite-with-php/</link>
		<comments>http://breathing-spring.com/starting-with-sqlite-with-php/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 14:57:55 +0000</pubDate>
		<dc:creator>Lamis</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://breathing-spring.com/?p=96</guid>
		<description><![CDATA[First of all you need to make sure that the extension of sqlite is working through the settings in php.ini
Assuming its working, I will make it brief first create a file names create_database.php
And add the following to it

$db= new SQLiteDatabase("db.sqlite");
$db-&#62;query("
BEGIN;
CREATE TABLE users (id INTEGER UNSIGNED PRIMARY KEY,
name CHAR(255),
email CHAR(255));
INSERT INTO users (id,name,email) VALUES (NULL,'User1','user1@domain.com');
insert into ]]></description>
			<content:encoded><![CDATA[<p>First of all you need to make sure that the extension of sqlite is working through the settings in php.ini</p>
<p>Assuming its working, I will make it brief first create a file names create_database.php<br />
And add the following to it</p>
<p><code><br />
$db= new SQLiteDatabase("db.sqlite");<br />
$db-&gt;query("<br />
BEGIN;<br />
CREATE TABLE users (id INTEGER UNSIGNED PRIMARY KEY,<br />
name CHAR(255),<br />
email CHAR(255));<br />
INSERT INTO users (id,name,email) VALUES (NULL,'User1','user1@domain.com');<br />
insert into users (id,name,email) values (NULL, 'user2','user2@lamis.com');<br />
insert into users (id,name,email) values (NULL, 'user3','user3@lamis.com');<br />
COMMIT;<br />
");<br />
</code><br />
This will create a new SQLiteDatabase and a table called users</p>
<p>now create another file call it test_result.php<br />
and add the following to it<br />
<code><br />
$db= new SQLiteDatabase(&#34;db.sqlite&#34;);<br />
$result = $db->query(&#34;Select * from users&#34;);<br />
echo &#34;&lt;br>&lt;br>++++++ POINTER WAY +++++++&lt;br>&lt;br>&#34;;<br />
while($result->valid())<br />
{<br />
	print_r($result->current());<br />
	echo &#34;&lt;br>&#34;;<br />
	$result->next();<br />
}<br />
echo &#34;&lt;br>&lt;br>++++++ ASSOCIATIVE WITH FETCH+++++++&lt;br>&lt;br>&#34;;<br />
$result = $db->query(&#34;Select * from users&#34;);<br />
while($row = $result->fetch(SQLITE_ASSOC))<br />
{<br />
	print_r($row);<br />
	echo &#34;&lt;br>&#34;;<br />
}<br />
echo &#34;&lt;br>&lt;br>++++++ NUM WITH FETCH+++++++&lt;br>&lt;br>&#34;;<br />
$result = $db->query(&#34;Select * from users&#34;);<br />
while($row = $result->fetch(SQLITE_NUM))<br />
{<br />
	print_r($row);<br />
	echo &#34;&lt;br>&#34;;<br />
}<br />
echo &#34;&lt;br>&lt;br>++++++ FETCH ALL ++++++&lt;br>&lt;br>&#34;;<br />
$result = $db->query(&#34;Select * from users&#34;);<br />
$rows= $result->fetchAll();<br />
foreach($rows as $row)<br />
{<br />
	print_r($row);<br />
	echo &#34;&lt;br>&#34;;<br />
}<br />
echo &#34;&lt;br>&lt;br>++++++ FETCH Object ++++++&lt;br>&lt;br>&#34;;<br />
$result = $db->query(&#34;Select * from users&#34;);<br />
while($row = $result->fetchObject())<br />
{<br />
	print_r($row);<br />
	echo &#34;&lt;br> you can call any like this \$row->id&lt;br>&lt;br>&lt;br>&#34;;<br />
}<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://breathing-spring.com/starting-with-sqlite-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>using curl as post</title>
		<link>http://breathing-spring.com/using-curl-as-post/</link>
		<comments>http://breathing-spring.com/using-curl-as-post/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 13:51:56 +0000</pubDate>
		<dc:creator>Lamis</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://breathing-spring.com/?p=88</guid>
		<description><![CDATA[First of all know this code work for something with no captcha
here how it goes

$url = "http://someurl.com";
$ch = curl_init();

The url is to specify the link for the post

// howmany parameter to post
curl_setopt($ch, CURLOPT_POST, 3);
// the parameter 'username' with its value 'johndoe'
curl_setopt($ch, CURLOPT_POSTFIELDS,"name=".$name."&#038;username=".$username.."&#038;email=".$email);
//TRUE to return the transfer as a string of the return value of curl_exec() ]]></description>
			<content:encoded><![CDATA[<p>First of all know this code work for something with no captcha</p>
<p>here how it goes<br />
<code><br />
$url = "http://someurl.com";<br />
$ch = curl_init();<br />
</code></p>
<p>The url is to specify the link for the post</p>
<p><code><br />
// howmany parameter to post<br />
curl_setopt($ch, CURLOPT_POST, 3);<br />
// the parameter 'username' with its value 'johndoe'<br />
curl_setopt($ch, CURLOPT_POSTFIELDS,"name=".$name."&#038;username=".$username.."&#038;email=".$email);<br />
//TRUE to return the transfer as a string of the return value of curl_exec() instead of outputting it out directly.<br />
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);<br />
$result= curl_exec ($ch);<br />
 curl_close ($ch);<br />
</code></p>
<p>We can also add some settings which can be useful , for instance to ignore redirection in the url we can add<br />
<code><br />
  curl_setopt($ch,CURLOPT_FOLLOWLOCATION, true);<br />
</code></p>
<p>Here is a link of the set of the things we can add</p>
<p>http://ca3.php.net/manual/en/function.curl-setopt.php</p>
]]></content:encoded>
			<wfw:commentRss>http://breathing-spring.com/using-curl-as-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>access associative array in_array</title>
		<link>http://breathing-spring.com/access-associative-array-in_array/</link>
		<comments>http://breathing-spring.com/access-associative-array-in_array/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 09:09:24 +0000</pubDate>
		<dc:creator>Lamis</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://breathing-spring.com/?p=83</guid>
		<description><![CDATA[so let me explain this
usually we have arrays like this
 $my_array= new Array ("US","UK", "FR") 
and to search for a value we do
if( in_array("FR", $my_array) )
the problem is when we have an associative array that has several values something like this
 $my_array= new Array ("US"=&#62;array(40,50) ,"UK"=&#62;array(46,60) , "FR"=&#62;array(70,50) ); 
now searching for FR wont be ]]></description>
			<content:encoded><![CDATA[<p>so let me explain this<br />
usually we have arrays like this</p>
<p><code> $my_array= new Array ("US","UK", "FR") </code><br />
and to search for a value we do<br />
<code>if( in_array("FR", $my_array) )</code></p>
<p>the problem is when we have an associative array that has several values something like this</p>
<p><code> $my_array= new Array ("US"=&gt;array(40,50) ,"UK"=&gt;array(46,60) , "FR"=&gt;array(70,50) ); </code></p>
<p>now searching for FR wont be possible with the previous way</p>
<p>so what we do is simple easy add!</p>
<p><code>if(in_array("FR" ,array_keys($my_array)))</code></p>
<p>enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://breathing-spring.com/access-associative-array-in_array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>get unique value from XML array</title>
		<link>http://breathing-spring.com/get-unique-value-from-xml-array/</link>
		<comments>http://breathing-spring.com/get-unique-value-from-xml-array/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 09:08:04 +0000</pubDate>
		<dc:creator>Lamis</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://breathing-spring.com/?p=76</guid>
		<description><![CDATA[this should work best as far as I know and tried..I used the serialize because oddly it couldnt compare strings
hope it maybe help someone there that needs it

$new=array();
$exclude = array("");
foreach ($myItems as $item)
{
if (!in_array(serialize($item-&#62;fileName) ,$exclude))
{
$new[] = $item;
array_push($exclude, serialize($item-&#62;fileName));
}
}
]]></description>
			<content:encoded><![CDATA[<p>this should work best as far as I know and tried..I used the serialize because oddly it couldnt compare strings</p>
<p>hope it maybe help someone there that needs it<br />
<code><br />
$new=array();</p>
<p>$exclude = array("");</p>
<p>foreach ($myItems as $item)<br />
{<br />
if (!in_array(serialize($item-&gt;fileName) ,$exclude))<br />
{<br />
$new[] = $item;<br />
array_push($exclude, serialize($item-&gt;fileName));<br />
}<br />
}</code></p>
]]></content:encoded>
			<wfw:commentRss>http://breathing-spring.com/get-unique-value-from-xml-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wrong And Rights</title>
		<link>http://breathing-spring.com/70/</link>
		<comments>http://breathing-spring.com/70/#comments</comments>
		<pubDate>Sun, 15 Mar 2009 19:37:02 +0000</pubDate>
		<dc:creator>Lamis</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://breathing-spring.com/?p=70</guid>
		<description><![CDATA[Switch statements:
// Always assume that the case got not catched
// Wrong 

switch ($mode)
{
	case 'mode1':
		// I am doing something here
		break;
	case 'mode2':
		// I am doing something completely different here
		break;
}

// Good 

switch ($mode)
{
	case 'mode1':
		// I am doing something here
	break;

	case 'mode2':
		// I am doing something completely different here
	break;

	default:
		// Always assume that the case got not catched
	break;
}

Operations in loop definition:
// ]]></description>
			<content:encoded><![CDATA[<p><strong>Switch statements:</strong><br />
// Always assume that the case got not catched</p>
<p class="bad"><span style="color: #ff0000;">// Wrong </span></p>
<div class="codebox">
<pre>switch ($mode)
{
	case 'mode1':
		// I am doing something here
		break;
	case 'mode2':
		// I am doing something completely different here
		break;
}</pre>
</div>
<p class="good"><span style="color: #99cc00;">// Good </span></p>
<div class="codebox">
<pre>switch ($mode)
{
	case 'mode1':
		// I am doing something here
	break;

	case 'mode2':
		// I am doing something completely different here
	break;

	default:
		// Always assume that the case got not catched
	break;
}</pre>
</div>
<p><strong>Operations in loop definition:</strong></p>
<p class="bad"><span style="color: #ff0000;">// On every iteration the sizeof function is called</span></p>
<div class="codebox">
<pre>for ($i = 0; $i &lt; sizeof($post_data); $i++)
{
	do_something();
}</pre>
</div>
<p class="good"><span style="color: #99cc00;">// You are able to assign the (not changing) result within the loop itself</span></p>
<div class="codebox">
<pre>for ($i = 0, $size = sizeof($post_data); $i &lt; $size; $i++)
{
	do_something();
}</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://breathing-spring.com/70/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>subtract current date with past date in PHP</title>
		<link>http://breathing-spring.com/subtract-current-date-with-past-date-in-php/</link>
		<comments>http://breathing-spring.com/subtract-current-date-with-past-date-in-php/#comments</comments>
		<pubDate>Sat, 30 Aug 2008 13:01:24 +0000</pubDate>
		<dc:creator>Lamis</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://breathing-spring.com/?p=41</guid>
		<description><![CDATA[&#60;?php
function subtract_dates($begin_date, $end_date)
{
return round(($end_date &#8211; $begin_date) / 86400);
}
$beginDate= mktime(0, 0, 0, 8, 30, 2008);
$currentDate= mktime();
echo subtract_dates($beginDate,$currentDate);
?&#62;
]]></description>
			<content:encoded><![CDATA[<p>&lt;?php<br />
function subtract_dates($begin_date, $end_date)<br />
{<br />
return round(($end_date &#8211; $begin_date) / 86400);<br />
}<br />
$beginDate= mktime(0, 0, 0, 8, 30, 2008);<br />
$currentDate= mktime();<br />
echo subtract_dates($beginDate,$currentDate);</p>
<p>?&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://breathing-spring.com/subtract-current-date-with-past-date-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Short Echo If Else Statment</title>
		<link>http://breathing-spring.com/short-echo-if-else-statment/</link>
		<comments>http://breathing-spring.com/short-echo-if-else-statment/#comments</comments>
		<pubDate>Sun, 03 Aug 2008 08:11:45 +0000</pubDate>
		<dc:creator>Lamis</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://breathing-spring.com/?p=33</guid>
		<description><![CDATA[there are two ways of doing short echo statment
&#60;?php echo condition? &#8220;right&#8221; : &#8220;left&#8221;;?&#62;
I beleive the above way is the best because it has standards, I heard from a friend that &#60;?php is very important. I know he is a geek about making things super perfect but anyways , I go with it.
There is a ]]></description>
			<content:encoded><![CDATA[<p>there are two ways of doing short echo statment</p>
<p>&lt;?php echo condition? &#8220;right&#8221; : &#8220;left&#8221;;?&gt;</p>
<p>I beleive the above way is the best because it has standards, I heard from a friend that &lt;?php is very important. I know he is a geek about making things super perfect but anyways , I go with it.</p>
<p>There is a shorter version which I dont prefer</p>
<p>&lt;?= echo condition? &#8220;right&#8221; : &#8220;left&#8221;;?&gt;</p>
<p>though both work but the first one is more right to me and to my computer geek friend <img src='http://breathing-spring.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://breathing-spring.com/short-echo-if-else-statment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>fetching one result from mysql</title>
		<link>http://breathing-spring.com/fetching-one-result-from-mysql/</link>
		<comments>http://breathing-spring.com/fetching-one-result-from-mysql/#comments</comments>
		<pubDate>Sun, 29 Jun 2008 08:21:39 +0000</pubDate>
		<dc:creator>Lamis</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://breathing-spring.com/?p=18</guid>
		<description><![CDATA[usually we use mysql queries to retrieve large  data contents.
But sometimes all we need is a number (Max, Count, or maybe just to retrieve unique feild). so we wont need to create an array.
to do so we can try the following code
$query=&#8221;select max(&#8216;num&#8217;) from table&#8221;;
$result=mysql_query(query);
//now the magic line
$MaxNum=mysql_result($result,0,0)
there must be a reason for the 0, ]]></description>
			<content:encoded><![CDATA[<p>usually we use mysql queries to retrieve large  data contents.</p>
<p>But sometimes all we need is a number (Max, Count, or maybe just to retrieve unique feild). so we wont need to create an array.</p>
<p>to do so we can try the following code</p>
<blockquote><p>$query=&#8221;select max(&#8216;num&#8217;) from table&#8221;;</p>
<p>$result=mysql_query(query);</p>
<p>//now the magic line</p>
<p>$MaxNum=mysql_result($result,0,0)</p></blockquote>
<p>there must be a reason for the 0, 0 but actually I dont know. if you know and can help me then I will be grateful.</p>
]]></content:encoded>
			<wfw:commentRss>http://breathing-spring.com/fetching-one-result-from-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
