<?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>Nisi's work blog &#187; Website&#8217;s</title>
	<atom:link href="http://wiki.nisi.ro/category/programming/websites/feed/" rel="self" type="application/rss+xml" />
	<link>http://wiki.nisi.ro</link>
	<description>Nisi's work blog - programing tips</description>
	<lastBuildDate>Mon, 21 Nov 2011 08:43:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>How to disable comments notification for WordPress</title>
		<link>http://wiki.nisi.ro/2011/11/how-to-disable-comments-notification-for-wordpress/</link>
		<comments>http://wiki.nisi.ro/2011/11/how-to-disable-comments-notification-for-wordpress/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 08:43:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[disable]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://wiki.nisi.ro/?p=408</guid>
		<description><![CDATA[Do you receive alot of emails sent by your WordPress Blog becouse people comment your posts? You can turn this off like this: 1. Login to your blog admin page 2. Click on Settings -&#62; Discussion 3. Search in that list for &#8220;E-mail me whenever:&#8221; Now by default you receive email when &#8220;Anyone posts a [...]]]></description>
			<content:encoded><![CDATA[<p>Do you receive alot of emails sent by your WordPress Blog becouse people comment your posts?</p>
<p>You can turn this off like this:</p>
<p>1. Login to your blog admin page</p>
<p>2. Click on Settings -&gt; Discussion</p>
<p>3. Search in that list for &#8220;<em>E-mail me whenever</em>:&#8221;</p>
<p>Now by default you receive email when &#8220;<em>Anyone posts a comment</em>&#8221; and &#8220;<em>A comment is held for moderation</em>&#8220;. Uncheck any or both of this options as you like.</p>
<p>You should definitely uncheck &#8220;Anyone posts a comment&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://wiki.nisi.ro/2011/11/how-to-disable-comments-notification-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unable to find the wrapper &#8220;https&#8221;</title>
		<link>http://wiki.nisi.ro/2011/10/unable-to-find-the-wrapper-https/</link>
		<comments>http://wiki.nisi.ro/2011/10/unable-to-find-the-wrapper-https/#comments</comments>
		<pubDate>Sat, 29 Oct 2011 05:07:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[PHP & MySQL]]></category>
		<category><![CDATA[apache module]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[facebook login]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php_openssl]]></category>
		<category><![CDATA[ssl_module]]></category>

		<guid isPermaLink="false">http://wiki.nisi.ro/?p=402</guid>
		<description><![CDATA[Today I had to put a simple script on one of my hosting server where a &#8220;Facebook Login&#8221; button was available for login. However when I had to run it I encountered the following error: Warning: file_get_contents() [function.file-get-contents]: Unable to find the wrapper &#8220;https&#8221; &#8211; did you forget to enable it when you configured PHP? [...]]]></description>
			<content:encoded><![CDATA[<p>Today I had to put a simple script on one of my hosting server where a &#8220;<strong><a href="http://developers.facebook.com/docs/guides/web/#login" target="_blank">Facebook Login</a></strong>&#8221; button was available for login. However when I had to run it I encountered the following error:</p>
<p><em><strong>Warning:</strong> file_get_contents() [function.file-get-contents]: Unable to find the wrapper &#8220;https&#8221; &#8211; did you forget to enable it when you configured PHP?</em></p>
<p>This was becouse the url served to <strong><em>file_get_contents</em></strong> start with http:// &#8230;.</p>
<p>If you have the same problem there are 2 steps to rezolve it:</p>
<ol>
<li>apache module ssl_module need to be avilble</li>
<li>php extension php_openssl need to be activated too</li>
</ol>
<p>Server restart and you are good to go.</p>
<p>To test from PHP is extension php_openssl is active just paste this code:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">if</span> <span class="br0">&#40;</span><a href="http://www.php.net/extension_loaded"><span class="kw3">extension_loaded</span></a><span class="br0">&#40;</span><span class="st0">&#8216;php_openssl&#8217;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<a href="http://www.php.net/echo"><span class="kw3">echo</span></a><span class="br0">&#40;</span><span class="st0">&#8216;php_openssl ok&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">else</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<a href="http://www.php.net/echo"><span class="kw3">echo</span></a><span class="br0">&#40;</span><span class="st0">&#8216;php_openssl off&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://wiki.nisi.ro/2011/10/unable-to-find-the-wrapper-https/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>$_FILES limitation when uploading files in PHP</title>
		<link>http://wiki.nisi.ro/2011/10/_files-limitation-when-uploading-files-in-php/</link>
		<comments>http://wiki.nisi.ro/2011/10/_files-limitation-when-uploading-files-in-php/#comments</comments>
		<pubDate>Fri, 14 Oct 2011 09:10:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP & MySQL]]></category>
		<category><![CDATA[$_FILES]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[javascriupt]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[upload file]]></category>

		<guid isPermaLink="false">http://wiki.nisi.ro/?p=395</guid>
		<description><![CDATA[Along with the &#8220;upload_max_filesize&#8221; when uploading files with PHP there is another parameter named &#8220;max_file_uploads&#8221; witch prevent uploading more files that the value of this parameter. Default size of this parameter is 20 and is should be enough for more apps then I can count but today I had to repair a bug in a [...]]]></description>
			<content:encoded><![CDATA[<p>Along with the &#8220;upload_max_filesize&#8221; when uploading files with PHP there is another parameter named &#8220;max_file_uploads&#8221; witch prevent uploading more files that the value of this parameter.</p>
<p>Default size of this parameter is 20 and is should be enough for more apps then I can count but today I had to repair a bug in a page where a form contain 30 file uploads and just 20 were availble in $_FILES from php script.</p>
<p><strong>How can you change this?</strong></p>
<p>There are 2 methods. One is to change it from php.ini but not always you can access php.ini file</p>
<p>The second method <strong>is not</strong> using ini_set :( . Tried that and not working.</p>
<p>I did find another method witch need some javascript. The method is when submiting the form a javascript will disable all unused upload elements like this:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">jQuery<span class="br0">&#40;</span><span class="st0">&quot;#upload_files1&quot;</span><span class="br0">&#41;</span>.<span class="me1">submit</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; jQuery<span class="br0">&#40;</span><span class="st0">&#8216;input:file[value=&quot;&quot;]&#8216;</span><span class="br0">&#41;</span>.<span class="me1">attr</span><span class="br0">&#40;</span><span class="st0">&quot;disabled&quot;</span>, <span class="kw2">true</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p>and the form:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&lt;form id=&quot;upload_files1&quot; enctype=&quot;multipart/form-data&quot; method=&quot;post&quot;&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;input name=&quot;img[]&quot; type=&quot;file&quot; /&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;input name=&quot;img[]&quot; type=&quot;file&quot; /&gt;
</div>
</li>
<li class="li2">
<div class="de2">&#8230;
</div>
</li>
<li class="li1">
<div class="de1">&lt;input name=&quot;img[]&quot; type=&quot;file&quot; /&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;input name=&quot;save&quot; type=&quot;submit&quot; value=&quot;Save&quot; /&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;/form&gt;</div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://wiki.nisi.ro/2011/10/_files-limitation-when-uploading-files-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use call_user_func_array with a simple function and with class methods</title>
		<link>http://wiki.nisi.ro/2011/05/how-to-use-call_user_func_array-with-a-simple-function-and-with-class-methods/</link>
		<comments>http://wiki.nisi.ro/2011/05/how-to-use-call_user_func_array-with-a-simple-function-and-with-class-methods/#comments</comments>
		<pubDate>Sat, 28 May 2011 11:49:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP & MySQL]]></category>
		<category><![CDATA[call_user_func_array]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[private]]></category>
		<category><![CDATA[static]]></category>

		<guid isPermaLink="false">http://wiki.nisi.ro/?p=386</guid>
		<description><![CDATA[In this post you will see a example of using call_user_func_array (from PHP) to call a simple function, a public static method from a class and a public method. First I define one function and one class: function add&#40;$p1, $p2&#41;&#123; &#160; &#160;return $p1 + $p2; &#125; &#160; class CSimpleMath&#123; &#160; &#160;function __construct&#40;$v1&#41; &#123; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>In this post you will see a example of using call_user_func_array (from PHP) to call a simple function, a public static method from a class and a public method.</p>
<p>First I define one function and one class:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">function</span> add<span class="br0">&#40;</span><span class="re0">$p1</span>, <span class="re0">$p2</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw1">return</span> <span class="re0">$p1</span> + <span class="re0">$p2</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2"><span class="kw2">class</span> CSimpleMath<span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw2">function</span> __construct<span class="br0">&#40;</span><span class="re0">$v1</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> &nbsp; &nbsp; &nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw2">public</span> <a href="http://www.php.net/static"><span class="kw3">static</span></a> <span class="kw2">function</span> multiply<span class="br0">&#40;</span><span class="re0">$a</span>, <span class="re0">$b</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$a</span> * <span class="re0">$b</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw2">public</span> <span class="kw2">function</span> substract<span class="br0">&#40;</span><span class="re0">$a</span>, <span class="re0">$b</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$b</span> &#8211; <span class="re0">$a</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw2">function</span> __destruct<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="br0">&#125;</span>&nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>Maybe you notice that in the class I did inserted a construct and destruct functions. You dont realy need them for this example to work but I always include them when I write a class.</p>
<p><strong>Call a simple function with call_user_func_array:</strong></p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <a href="http://www.php.net/call_user_func_array"><span class="kw3">call_user_func_array</span></a><span class="br0">&#40;</span><span class="st0">&#8216;add&#8217;</span>, <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="nu0">2</span>, <span class="nu0">5</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p><strong>Call a public static method:</strong></p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <a href="http://www.php.net/call_user_func_array"><span class="kw3">call_user_func_array</span></a><span class="br0">&#40;</span><span class="st0">&#8216;CSimpleMath::multiply&#8217;</span>, <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="nu0">2</span>, <span class="nu0">5</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p><strong>Call a public class method</strong></p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><a href="http://www.php.net/call_user_func_array"><span class="kw3">call_user_func_array</span></a><span class="br0">&#40;</span><a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&#8216;CSimpleMath&#8217;</span>, <span class="st0">&#8216;substract&#8217;</span><span class="br0">&#41;</span>, <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="nu0">2</span>, <span class="nu0">5</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://wiki.nisi.ro/2011/05/how-to-use-call_user_func_array-with-a-simple-function-and-with-class-methods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;Progress bar&#8221; for long running cron scripts in PHP</title>
		<link>http://wiki.nisi.ro/2011/05/progress-bar-for-long-running-cron-scripts-in-php/</link>
		<comments>http://wiki.nisi.ro/2011/05/progress-bar-for-long-running-cron-scripts-in-php/#comments</comments>
		<pubDate>Thu, 12 May 2011 13:43:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP & MySQL]]></category>
		<category><![CDATA[Website's]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[cron progress]]></category>
		<category><![CDATA[email progress bar]]></category>
		<category><![CDATA[long running]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://wiki.nisi.ro/?p=381</guid>
		<description><![CDATA[Long running scripts can be a pain if you dont know how much will be running. If you need to see a progress and flush() or ob_flush() do not work becouse of browser cache you can implement an &#8220;email progress bar&#8221;. PHP example: $step = 0; $last_percent = 0; $total_rows = while&#40;1&#41; &#123; &#160; &#160;$step++; [...]]]></description>
			<content:encoded><![CDATA[<p>Long running scripts can be a pain if you dont know how much will be running. If you need to see a progress and flush() or ob_flush() do not work becouse of browser cache you can implement an &#8220;email progress bar&#8221;.</p>
<p><strong>PHP example:</strong></p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="re0">$step</span> = <span class="nu0">0</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$last_percent</span> = <span class="nu0">0</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$total_rows</span> =</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">while</span><span class="br0">&#40;</span><span class="nu0">1</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp;<span class="re0">$step</span>++; <span class="co1">//count step</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="co1">// here should be is the code witch consume time for every loop</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="co1">// end consuming time code</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp;<span class="re0">$procent</span> = <span class="br0">&#40;</span><span class="re0">$step</span> * <span class="nu0">100</span><span class="br0">&#41;</span> / <span class="re0">$total_rows</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$last_percent</span> != <a href="http://www.php.net/round"><span class="kw3">round</span></a><span class="br0">&#40;</span><span class="re0">$procent</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#123;</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="co1">// becouse you do not want to receive an email for every step</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="re0">$last_percent</span> = <a href="http://www.php.net/round"><span class="kw3">round</span></a><span class="br0">&#40;</span><span class="re0">$procent</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="br0">&#40;</span><span class="re0">$last_percent</span> % <span class="nu0">10</span><span class="br0">&#41;</span> == <span class="nu0">0</span><span class="br0">&#41;</span><span class="br0">&#123;</span> &nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">// this will send email from 10 % to 10 % &#8211; total 10 emails</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.php.net/mail"><span class="kw3">mail</span></a><span class="br0">&#40;</span>your_email_here, <span class="st0">&#8216;Progress &#8216;</span>.<span class="re0">$last_percent</span>.<span class="st0">&#8216;% done&#8217;</span> , <span class="st0">&quot;Progress: &quot;</span>.<span class="re0">$contor</span>.<span class="st0">&quot;/&quot;</span>.<span class="re0">$total_rows</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2"><span class="br0">&#125;</span> <span class="co1">// end while</span></div>
</li>
</ol>
</div>
<p>As you can see the ideea is very simple and you can implement it in any language.</p>
]]></content:encoded>
			<wfw:commentRss>http://wiki.nisi.ro/2011/05/progress-bar-for-long-running-cron-scripts-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to replace substring in MySQL table field</title>
		<link>http://wiki.nisi.ro/2011/03/how-to-replace-substring-in-mysql-table-field/</link>
		<comments>http://wiki.nisi.ro/2011/03/how-to-replace-substring-in-mysql-table-field/#comments</comments>
		<pubDate>Fri, 11 Mar 2011 12:30:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP & MySQL]]></category>
		<category><![CDATA[instr]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[replace]]></category>
		<category><![CDATA[update]]></category>
		<category><![CDATA[where]]></category>

		<guid isPermaLink="false">http://wiki.nisi.ro/?p=368</guid>
		<description><![CDATA[This replace will search in every row of the table where condition from WHERE is true and replace function will replace all instances in a string. ex. if you have text &#8220;hello world&#8221; and you want to replace the &#8220;o&#8221; letter with &#8220;*&#8221; this will will transform the text in &#8220;hell* w*rld&#8221; UPDATE `mytable` SET [...]]]></description>
			<content:encoded><![CDATA[<p>This replace will search in every row of the table where condition from WHERE is true and replace function will replace all instances in a string.</p>
<p>ex. if you have text &#8220;hello world&#8221; and you want to replace the &#8220;o&#8221; letter with &#8220;*&#8221; this will will transform the text in &#8220;hell* w*rld&#8221;</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">UPDATE</span> `mytable`</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">SET</span> my_content = <span class="kw1">REPLACE</span><span class="br0">&#40;</span>content, <span class="st0">&#8216;substr_string_to_replace&#8217;</span>,<span class="st0">&#8216;the_new_string&#8217;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">WHERE</span> <span class="kw1">INSTR</span><span class="br0">&#40;</span>content, <span class="st0">&#8216;substr_string_to_replace&#8217;</span><span class="br0">&#41;</span> &gt; <span class="nu0">0</span>;</div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://wiki.nisi.ro/2011/03/how-to-replace-substring-in-mysql-table-field/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP: trim spaces in the middle of a string</title>
		<link>http://wiki.nisi.ro/2011/02/php-trim-spaces-in-the-middle-of-a-string/</link>
		<comments>http://wiki.nisi.ro/2011/02/php-trim-spaces-in-the-middle-of-a-string/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 11:29:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP & MySQL]]></category>
		<category><![CDATA[colapse]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[space]]></category>
		<category><![CDATA[trim]]></category>

		<guid isPermaLink="false">http://wiki.nisi.ro/?p=365</guid>
		<description><![CDATA[When you let users input text in a textfield or input box iti is always a good ideea to use trim function to remove spaces form the begining or the end of the string. Today I needed a function to trim spaces from the middle of a string and replace with a single space. /* [...]]]></description>
			<content:encoded><![CDATA[<p>When you let users input text in a textfield or input box iti is always a good ideea to use trim function to remove spaces form the begining or the end of the string.</p>
<p>Today I needed a function to trim spaces from the middle of a string and replace with a single space.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="coMULTI">/* </span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">&nbsp; &nbsp; this will return the string where groups of consecutive spaces </span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">&nbsp; &nbsp; are collapsed in a single space</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">&nbsp; &nbsp; </span></div>
</li>
<li class="li2">
<div class="de2"><span class="coMULTI">&nbsp; &nbsp; eg. $str = &quot;This is &nbsp; &nbsp;my test &nbsp; &nbsp;string&quot;;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">&nbsp; &nbsp; function will output &quot;This is my test string&quot; </span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">&nbsp;*/</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> centerTrim<span class="br0">&#40;</span><span class="re0">$str</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">return</span> <a href="http://www.php.net/preg_replace"><span class="kw3">preg_replace</span></a><span class="br0">&#40;</span><span class="st0">&quot;/<span class="es0">\s</span>+/&quot;</span>, <span class="st0">&quot; &quot;</span>, <span class="re0">$str</span><span class="br0">&#41;</span></div>
</li>
<li class="li2">
<div class="de2"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>if you need to remove all spaces you can use this function:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="coMULTI">/* </span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">&nbsp; &nbsp; eg. $str = &quot;This is &nbsp; &nbsp;my test &nbsp; &nbsp;string&quot;;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">&nbsp; &nbsp; function will output &quot;Thisismyteststring&quot; </span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">&nbsp;*/</span></div>
</li>
<li class="li2">
<div class="de2"><span class="kw2">function</span> centerTrim2<span class="br0">&#40;</span><span class="re0">$str</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">return</span> <a href="http://www.php.net/preg_replace"><span class="kw3">preg_replace</span></a><span class="br0">&#40;</span><span class="st0">&quot;/<span class="es0">\s</span>+/&quot;</span>, <span class="st0">&quot;&quot;</span>, <span class="re0">$str</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://wiki.nisi.ro/2011/02/php-trim-spaces-in-the-middle-of-a-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL: Select &#8220;last month&#8221; records</title>
		<link>http://wiki.nisi.ro/2011/02/mysql-select-last-month-records/</link>
		<comments>http://wiki.nisi.ro/2011/02/mysql-select-last-month-records/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 12:27:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP & MySQL]]></category>
		<category><![CDATA[last month]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[records]]></category>

		<guid isPermaLink="false">http://wiki.nisi.ro/?p=363</guid>
		<description><![CDATA[In order to select last month records you have to get first dai of the last month and the last day of the first month. Remember that current month could be January and the last month will in another year. Finding first day of the last month: DATE_FORMAT&#40;CURRENT_DATE &#8211; INTERVAL 1 MONTH, &#34;%Y-%m-01&#34;&#41; Finding the [...]]]></description>
			<content:encoded><![CDATA[<p>In order to select last month records you have to get first dai of the last month and the last day of the first month.</p>
<p>Remember that current month could be January and the last month will in another year.</p>
<p>Finding first day of the last month:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">DATE_FORMAT</span><span class="br0">&#40;</span><span class="kw1">CURRENT_DATE</span> &#8211; <span class="kw1">INTERVAL</span> <span class="nu0">1</span> <span class="kw4">MONTH</span>, <span class="st0">&quot;%Y-%m-01&quot;</span><span class="br0">&#41;</span></div>
</li>
</ol>
</div>
<p>Finding the last thay of the last month:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">LAST_DAY</span><span class="br0">&#40;</span><span class="kw1">CURRENT_DATE</span> &#8211; <span class="kw1">INTERVAL</span> <span class="nu0">1</span> <span class="kw4">MONTH</span><span class="br0">&#41;</span></div>
</li>
</ol>
</div>
<p>And the final Query is:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">SELECT</span> *</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">FROM</span> `my_table`</div>
</li>
<li class="li1">
<div class="de1">`<span class="kw2">DATE</span>` <span class="kw5">BETWEEN</span> <span class="kw1">DATE_FORMAT</span><span class="br0">&#40;</span><span class="kw1">CURRENT_DATE</span> &#8211; <span class="kw1">INTERVAL</span> <span class="nu0">1</span> <span class="kw4">MONTH</span>, <span class="st0">&quot;%Y-%m-01&quot;</span><span class="br0">&#41;</span> <span class="kw5">AND</span> <span class="kw1">LAST_DAY</span><span class="br0">&#40;</span><span class="kw1">CURRENT_DATE</span> &#8211; <span class="kw1">INTERVAL</span> <span class="nu0">1</span> <span class="kw4">MONTH</span><span class="br0">&#41;</span></div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://wiki.nisi.ro/2011/02/mysql-select-last-month-records/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL: select &#8220;this month&#8221; records</title>
		<link>http://wiki.nisi.ro/2011/02/mysql-select-this-month-records/</link>
		<comments>http://wiki.nisi.ro/2011/02/mysql-select-this-month-records/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 12:20:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP & MySQL]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[select this month]]></category>

		<guid isPermaLink="false">http://wiki.nisi.ro/?p=361</guid>
		<description><![CDATA[Where &#8220;date&#8221; column is a Date type in &#8220;my_table&#8221; SELECT * FROM `my_table` WHERE YEAR&#40;`DATE`&#41; = YEAR&#40;CURDATE&#40;&#41;&#41; AND MONTH&#40;`DATE`&#41; = MONTH&#40;CURDATE&#40;&#41;&#41;]]></description>
			<content:encoded><![CDATA[<p>Where &#8220;date&#8221; column is a Date type in &#8220;my_table&#8221;</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">SELECT</span> * </div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">FROM</span> `my_table`</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">WHERE</span> <span class="kw2">YEAR</span><span class="br0">&#40;</span>`<span class="kw2">DATE</span>`<span class="br0">&#41;</span> = <span class="kw2">YEAR</span><span class="br0">&#40;</span><span class="kw1">CURDATE</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="kw5">AND</span> <span class="kw4">MONTH</span><span class="br0">&#40;</span>`<span class="kw2">DATE</span>`<span class="br0">&#41;</span> = <span class="kw4">MONTH</span><span class="br0">&#40;</span><span class="kw1">CURDATE</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://wiki.nisi.ro/2011/02/mysql-select-this-month-records/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL: Select last 7 days records</title>
		<link>http://wiki.nisi.ro/2011/02/mysql-select-last-7-days-records/</link>
		<comments>http://wiki.nisi.ro/2011/02/mysql-select-last-7-days-records/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 12:14:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP & MySQL]]></category>
		<category><![CDATA[last 7 days]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[select]]></category>

		<guid isPermaLink="false">http://wiki.nisi.ro/?p=357</guid>
		<description><![CDATA[For this example I use this table model: ID Name Date 1 Jon Dow 2011-01-10 2 Jane Dow 2011-01-10 … … … SELECT * FROM `my_table` WHERE `DATE` BETWEEN DATE_ADD&#40;CURDATE&#40;&#41;, INTERVAL -5 DAY&#41; AND CURDATE&#40;&#41;]]></description>
			<content:encoded><![CDATA[<p>For this example I use this table model:</p>
<table border="1" style="margin-bottom: 20px;">
<tbody>
<tr>
<td>ID</td>
<td>Name</td>
<td>Date</td>
</tr>
<tr>
<td>1</td>
<td>Jon Dow</td>
<td>2011-01-10</td>
</tr>
<tr>
<td>2</td>
<td>Jane Dow</td>
<td>2011-01-10</td>
</tr>
<tr>
<td>…</td>
<td>…</td>
<td>…</td>
</tr>
</tbody>
</table>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">SELECT</span> *</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">FROM</span> `my_table`</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">WHERE</span> `<span class="kw2">DATE</span>` <span class="kw5">BETWEEN</span> <span class="kw1">DATE_ADD</span><span class="br0">&#40;</span><span class="kw1">CURDATE</span><span class="br0">&#40;</span><span class="br0">&#41;</span>, <span class="kw1">INTERVAL</span> <span class="nu0">-5</span> <span class="kw1">DAY</span><span class="br0">&#41;</span> <span class="kw5">AND</span> <span class="kw1">CURDATE</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://wiki.nisi.ro/2011/02/mysql-select-last-7-days-records/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

