<?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>Vinodkram &#187; PHP</title>
	<atom:link href="http://www.vinodkram.com/category/php/feed" rel="self" type="application/rss+xml" />
	<link>http://www.vinodkram.com</link>
	<description>Creative, Informative and Entertaining Stuff for everyone</description>
	<lastBuildDate>Mon, 26 Dec 2011 18:34:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>configure database using propel</title>
		<link>http://www.vinodkram.com/configure-database-using-propel</link>
		<comments>http://www.vinodkram.com/configure-database-using-propel#comments</comments>
		<pubDate>Mon, 26 Dec 2011 18:34:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MVC]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.vinodkram.com/?p=1614</guid>
		<description><![CDATA[$ ./symfony configure:database --name=propel --class=sfPropelDatabase "mysql:host=localhost;dbname=dbname" username userpassword]]></description>
			<content:encoded><![CDATA[<pre><code>$ ./symfony configure:database --name=propel --class=sfPropelDatabase "mysql:host=localhost;dbname=dbname" username userpassword</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.vinodkram.com/configure-database-using-propel/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get the allowed option list in drupal theme template or view file</title>
		<link>http://www.vinodkram.com/how-to-get-the-allowed-option-list-in-drupal-theme-template-or-view-file</link>
		<comments>http://www.vinodkram.com/how-to-get-the-allowed-option-list-in-drupal-theme-template-or-view-file#comments</comments>
		<pubDate>Thu, 15 Dec 2011 09:45:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.vinodkram.com/?p=1609</guid>
		<description><![CDATA[If you want to get the option list of the content type that you have created , then you can get the list as follows: $content_field = content_fields(&#8216;whatever_the_field_name_is&#8217;); $allowed_values = content_allowed_values($content_field); So the $allowed_values will give you the array of the option list with the key value association. Note: The &#8220;whatever_the_field_name_is&#8221; is the field name [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to get the option list of the content type that you have created , then you can get the list as follows:</p>
<p>$content_field = content_fields(&#8216;whatever_the_field_name_is&#8217;);<br />
$allowed_values = content_allowed_values($content_field);</p>
<p>So the $allowed_values will give you the array of the option list with the key value association.</p>
<p><strong>Note:</strong> The &#8220;whatever_the_field_name_is&#8221; is the field name that you had specified while adding the field, you can get the field name from your content type .</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vinodkram.com/how-to-get-the-allowed-option-list-in-drupal-theme-template-or-view-file/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to add select option in drupal while creating content type</title>
		<link>http://www.vinodkram.com/how-to-add-select-option-in-drupal-while-creating-content-type</link>
		<comments>http://www.vinodkram.com/how-to-add-select-option-in-drupal-while-creating-content-type#comments</comments>
		<pubDate>Thu, 15 Dec 2011 09:39:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.vinodkram.com/?p=1607</guid>
		<description><![CDATA[Whenever you create any content type in drupal ( version 6 and above) and you required a filed of type select list, then you can provide the allowed values of the select option in two ways CASE 1 : option 1 option 2 option 3 CASE 2 : 1&#124;option 1 2&#124;option 2 3&#124;option 3 Each [...]]]></description>
			<content:encoded><![CDATA[<p>Whenever you create any content type in drupal ( version 6 and above) and you required a filed of type select list, then you can provide the allowed values of the select option in two ways</p>
<p><strong>CASE 1 :</strong></p>
<p>option 1<br />
option 2<br />
option 3</p>
<p><strong>CASE 2 : </strong></p>
<p>1|option 1<br />
2|option 2<br />
3|option 3</p>
<p>Each new option has to be entered on a new line<br />
So enternally the select list generated would be as follows<br />
<strong>In case 1 : </strong></p>
<p>&lt;select&gt;<br />
&lt;option value=&#8221;option 1&#8243;&gt;option 1&lt;/option&gt;<br />
&lt;option value=&#8221;option 2&#8243;&gt;option 2&lt;/option&gt;<br />
&lt;option value=&#8221;option 3&#8243;&gt;option 3&lt;/option&gt;<br />
&lt;/select&gt;</p>
<p><strong>In case 2 : </strong></p>
<p>&lt;select&gt;<br />
&lt;option value=&#8221;1&#8243;&gt;option 1&lt;/option&gt;<br />
&lt;option value=&#8221;2&#8243;&gt;option 2&lt;/option&gt;<br />
&lt;option value=&#8221;3&#8243;&gt;option 3&lt;/option&gt;<br />
&lt;/select&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vinodkram.com/how-to-add-select-option-in-drupal-while-creating-content-type/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Replace multiple space with single space in PHP</title>
		<link>http://www.vinodkram.com/replace-multiple-space-with-single-space-in-php</link>
		<comments>http://www.vinodkram.com/replace-multiple-space-with-single-space-in-php#comments</comments>
		<pubDate>Wed, 14 Dec 2011 06:40:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.vinodkram.com/?p=1604</guid>
		<description><![CDATA[If you want to replace multiple space with single space from a string you can use preg_replace function for this. Refer the below example preg_replace(&#8220;!\s+!&#8221;,&#8221; &#8220;,$yourstring); For example $yourstring = &#8220;This contain space&#8221;; $modifiedString = preg_replace(&#8220;!\s+!&#8221;,&#8221; &#8220;,$yourstring); echo $modifiedString; // This contain space // output]]></description>
			<content:encoded><![CDATA[<p>If you want to replace multiple space with single space from a string you can use <a href="http://in.php.net/manual/en/function.preg-replace.php" target="_blank">preg_replace</a> function for this. Refer the below example</p>
<p>preg_replace(&#8220;!\s+!&#8221;,&#8221; &#8220;,$yourstring);</p>
<p>For example<br />
$yourstring = &#8220;This contain     space&#8221;;<br />
$modifiedString = preg_replace(&#8220;!\s+!&#8221;,&#8221; &#8220;,$yourstring);<br />
echo $modifiedString;<br />
//  This contain space // output</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vinodkram.com/replace-multiple-space-with-single-space-in-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get symfony project base url in template file</title>
		<link>http://www.vinodkram.com/how-to-get-symfony-project-base-url-in-template-file</link>
		<comments>http://www.vinodkram.com/how-to-get-symfony-project-base-url-in-template-file#comments</comments>
		<pubDate>Sat, 03 Dec 2011 11:17:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.vinodkram.com/?p=1595</guid>
		<description><![CDATA[To get the base url of your symfony project , you can use the below in your template file. $sf_request->getUriPrefix().$sf_request->getRelativeUrlRoot() And to get your current app URL. $sf_request->getUriPrefix().$sf_request->getRelativeUrlRoot().$sf_request->getPathInfoPrefix();]]></description>
			<content:encoded><![CDATA[<p>To get the base url of your symfony project , you can use the below in your template file.</p>
<p>$sf_request->getUriPrefix().$sf_request->getRelativeUrlRoot()</p>
<p>And to get your current app URL.</p>
<p>$sf_request->getUriPrefix().$sf_request->getRelativeUrlRoot().$sf_request->getPathInfoPrefix();</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vinodkram.com/how-to-get-symfony-project-base-url-in-template-file/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to check PHP error before including any file in your script</title>
		<link>http://www.vinodkram.com/how-to-check-php-error-before-including-any-file-in-your-script</link>
		<comments>http://www.vinodkram.com/how-to-check-php-error-before-including-any-file-in-your-script#comments</comments>
		<pubDate>Wed, 23 Feb 2011 05:42:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.vinodkram.com/?p=1565</guid>
		<description><![CDATA[Suppose you want to include/require any file in your scripts, But before doing so you want to confirm that the included or required file doesn&#8217;t contain error. Then in that case you can use the below code to do the same. /* Implementation */]]></description>
			<content:encoded><![CDATA[<p>Suppose you want to include/require any file in your scripts, But before doing so you want to confirm that the included or required file doesn&#8217;t contain error. Then in that case you can use the below code to do the same.</p>
<p>/* Implementation */</p>
<p><?php</p>
<p>$filePath = "the physical loaction of the file";<br />
if(chechFileSyntax($filePath))<br />
{<br />
	include($filePath); // OR require($filePath);<br />
}<br />
else<br />
{</p>
<p>	echo "The included file contain error";<br />
}</p>
<p>function chechFileSyntax($fileName)<br />
{</p>
<p>	if(file_exists($fileName) &#038;&#038; is_readable($fileName))<br />
	{<br />
		$checkSyntax = shell_exec('php -l '.$fileName);<br />
		if(preg_match("/No/",$checkSyntax))<br />
		{<br />
			return true; // No error<br />
		}<br />
		else<br />
		{<br />
			return false; // Contain Error<br />
		}<br />
	}<br />
}<br />
?></p>
]]></content:encoded>
			<wfw:commentRss>http://www.vinodkram.com/how-to-check-php-error-before-including-any-file-in-your-script/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to check if requested url exits or not</title>
		<link>http://www.vinodkram.com/how-to-check-if-requested-url-exits-or-not</link>
		<comments>http://www.vinodkram.com/how-to-check-if-requested-url-exits-or-not#comments</comments>
		<pubDate>Thu, 10 Feb 2011 16:01:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.vinodkram.com/?p=1561</guid>
		<description><![CDATA[$requestedUrl = &#8220;http://www.example.com/abc.php&#8221;; $tags = get_headers($requestedUrl); if(preg_match(&#8220;/Not Found/i&#8221;,$tags[0]) &#124;&#124; preg_match(&#8220;/Service Unavailable/i&#8221;,$tags[0])) { echo &#8220;Requested Url does not exists&#8221;; } else { echo &#8220;Requested Url exists&#8221;; }]]></description>
			<content:encoded><![CDATA[<p>$requestedUrl = &#8220;http://www.example.com/abc.php&#8221;;<br />
$tags = get_headers($requestedUrl);<br />
if(preg_match(&#8220;/Not Found/i&#8221;,$tags[0]) || preg_match(&#8220;/Service Unavailable/i&#8221;,$tags[0]))<br />
{<br />
	echo &#8220;Requested Url does not exists&#8221;;<br />
}<br />
else<br />
{<br />
	echo &#8220;Requested Url exists&#8221;;<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vinodkram.com/how-to-check-if-requested-url-exits-or-not/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>export data to excel file (.xls format)</title>
		<link>http://www.vinodkram.com/export-data-to-excel-file-xls-format</link>
		<comments>http://www.vinodkram.com/export-data-to-excel-file-xls-format#comments</comments>
		<pubDate>Sat, 31 Jul 2010 10:17:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[export to excel]]></category>

		<guid isPermaLink="false">http://www.vinodkram.com/?p=1535</guid>
		<description><![CDATA[By using the below code you can export your data from the database to excel file. When you run the below code, the excel file get generated and get downloaded to the client machine.]]></description>
			<content:encoded><![CDATA[<p>By using the below code you can export your data from the database to excel file.<br />
When you run the below code, the excel file get generated and get downloaded to the client machine.</p>
<p><?php</p>
<p>$file_name = "Name_of_excel_file";<br />
header("Content-type: application/vnd.ms-excel");<br />
header("Content-Disposition: attachment; filename=\"$file_name.xls\"");<br />
echo "\t Put_your_headline_for_the_excelfile ";<br />
echo "\n\n";<br />
// Here put the column title<br />
$heading = "Column_1_title \t Column_2_title \t Column_3_title\t Column_4_title \t Column_5_title \t\n\n";<br />
echo $heading;<br />
$data = '';</p>
<p>$conn = mysql_connect("localhost", "mysql_user", "mysql_password");<br />
if (!$conn)<br />
{<br />
    echo "Unable to connect to DB: " . mysql_error();<br />
    exit;<br />
}</p>
<p>if (!mysql_select_db("mydbname"))<br />
{<br />
    echo "Unable to select mydbname: " . mysql_error();<br />
    exit;<br />
}</p>
<p>$sql = "SELECT column_1, column_2, column_3, column_4, column_5<br />
        FROM   sometable<br />
        WHERE  somecondition = 1";</p>
<p>$result = mysql_query($sql);</p>
<p>if (!$result) {<br />
    echo "Could not successfully run query ($sql) from DB: " . mysql_error();<br />
    exit;<br />
}</p>
<p>if (mysql_num_rows($result) == 0) {<br />
    echo "No rows found, nothing to print so am exiting";<br />
    exit;<br />
}</p>
<p>// Note: If you're expecting just one row, no need to use a while loop<br />
while ($row = mysql_fetch_assoc($result))<br />
{</p>
<p>    echo $data = $row["column_1"]."\t".$row["column_2"]."\t".$row["column_3"]."\t".$row["column_4"]."\t".$row["column_5"]."\t\n";<br />
}<br />
mysql_free_result($result);<br />
?></p>
]]></content:encoded>
			<wfw:commentRss>http://www.vinodkram.com/export-data-to-excel-file-xls-format/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GD support</title>
		<link>http://www.vinodkram.com/gd-support</link>
		<comments>http://www.vinodkram.com/gd-support#comments</comments>
		<pubDate>Sat, 11 Jul 2009 15:10:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.vinodkram.com/?p=70</guid>
		<description><![CDATA[How to check if GD support is enabled or not. &#60;?php var_dump(gd_info()); ?&#62; If GD support is enabled then you will get an array in that you will get &#8220;GD Version&#8221;. If you didn&#8217;t get this that means GD support is not there . To enable GD support you should install GD library by the [...]]]></description>
			<content:encoded><![CDATA[<p>How to check if GD support is enabled or not.</p>
<p>&lt;?php<br />
var_dump(gd_info());<br />
?&gt;</p>
<p>If GD support is enabled then you will get  an array in that you will get &#8220;GD Version&#8221;.</p>
<p>If you didn&#8217;t get this that means GD support is not there .</p>
<p>To enable GD support you should install<br />
GD library by the below command<br />
&#8220;yum install php-gd&#8221; (Fedora Linux)<br />
This will install GD support.</p>
<p>Now when you check the output of the above php code it will display the GD version</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vinodkram.com/gd-support/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Calculate no of years,month,days,hours,minutes and seconds past since given date</title>
		<link>http://www.vinodkram.com/calculate-no-of-yearsmonthdayshoursminutes-and-seconds-past-since-given-date</link>
		<comments>http://www.vinodkram.com/calculate-no-of-yearsmonthdayshoursminutes-and-seconds-past-since-given-date#comments</comments>
		<pubDate>Sat, 10 Jan 2009 19:59:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[date]]></category>

		<guid isPermaLink="false">http://vinodkram.wordpress.com/?p=41</guid>
		<description><![CDATA[function getYMDHMSPastFromTwoDate($startTimeStamp,$endTimeStamp) { $years = &#8221;; $Month = &#8221;; $Days = &#8221;; $Hrs = &#8221;; $Mins = &#8221;; $totalSecs = &#8221;; $timePastArr = array(); $date1 = $startTimeStamp; $date2 = $endTimeStamp; if($date1 > $date2) { $dateDiff = intval($date1 &#8211; $date2); } else { $dateDiff = intval($date2 &#8211; $date1); } $totalYears = $dateDiff/(365*24*60*60); $years = floor($totalYears); $timeRemaining [...]]]></description>
			<content:encoded><![CDATA[<p>function getYMDHMSPastFromTwoDate($startTimeStamp,$endTimeStamp)<br />
{<br />
	$years = &#8221;;<br />
	$Month = &#8221;;<br />
	$Days = &#8221;;<br />
	$Hrs = &#8221;;<br />
	$Mins = &#8221;;<br />
	$totalSecs = &#8221;;<br />
	$timePastArr = array();<br />
	$date1 = $startTimeStamp;<br />
	$date2 = $endTimeStamp;<br />
	if($date1 > $date2)<br />
	{<br />
		$dateDiff = intval($date1 &#8211; $date2);<br />
	}<br />
	else<br />
	{<br />
		$dateDiff = intval($date2 &#8211; $date1);<br />
	}</p>
<p>	$totalYears = $dateDiff/(365*24*60*60);<br />
	$years = floor($totalYears);<br />
	$timeRemaining = ($dateDiff &#8211; ($years*365*24*60*60));<br />
	$totalMonth = $timeRemaining/(30*24*60*60);<br />
	$Month = floor($totalMonth);<br />
	$timeRemaining = $timeRemaining &#8211; $Month*30*24*60*60;<br />
	$totalDays = $timeRemaining/(24*60*60);<br />
	$Days = floor($totalDays);<br />
	$timeRemaining = $timeRemaining-$Days*60*60*24;<br />
	$totalHrs = $timeRemaining/(60*60);<br />
	$Hrs = floor($totalHrs);<br />
	$timeRemaining = $timeRemaining-$Hrs*60*60;<br />
	$totalMins = $timeRemaining/60;<br />
	$Mins = floor($totalMins);<br />
	$timeRemaining = $timeRemaining-$Mins*60;<br />
	$totalSecs = floor($timeRemaining);</p>
<p>	return $timePastArr = array(&#8216;year&#8217;=>$years,&#8217;month&#8217;=>$Month,&#8217;days&#8217;=>$Days,&#8217;hours&#8217;=>$Hrs,&#8217;minutes&#8217;=>$Mins,&#8217;seconds&#8217;=>$totalSecs);</p>
<p>}</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vinodkram.com/calculate-no-of-yearsmonthdayshoursminutes-and-seconds-past-since-given-date/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

