tag:blogger.com,1999:blog-18593884054146895782024-02-19T15:57:15.377+05:30TechniqZoneA Technical Guide for Developers.Unknownnoreply@blogger.comBlogger90125tag:blogger.com,1999:blog-1859388405414689578.post-39277272603408949672014-08-26T19:55:00.001+05:302014-08-26T19:55:27.130+05:30preg_replace to add something after closing tag - PHP<p><img alt="preg_replace to add something after closing tag - PHP" src="https://media.phpnuke.org/000/977/680/e52_6f1_580_580-4---phpnuke.jpg" style="height:188px; width:250px" /></p>
<p><span style="font-size:14px"><span style="color:rgb(165, 42, 42)"><strong>PHP - preg_replace to add something after closing tag :</strong></span></span></p>
<p>Here i will explain how to add something like string, char (or) any html tag after closing tag. Here we are using preg_replace() function to do it.</p>
<p>In the below example, add <br /> tag after closing of all <img> tag.</p>
<p><strong>Syntax :</strong></p>
<p> <span style="color:#A52A2A"><strong>preg_replace('/(<img[^>]+>(?:<\/img>)?)/i', '$1<br />', $str);</strong></span><br />
<br />
Note : This will match with <img />, <img>, <img></img> all of it.</p>
<p><strong>Example :</strong></p>
<p> <strong><span style="color:#A52A2A"><?php<br />
<br />
$str = "<img src='img_path'>TechniqZone<img src='img_path'>";<br />
echo preg_replace('/(<img[^>]+>(?:<\/img>)?)/i', '$1<br />', $str);<br />
<br />
?></span></strong><br />
<br />
<strong>Output :</strong></p>
<p> <span style="color:#A52A2A"><strong><img src='img_path'><br />TechniqZone<img src='img_path'><br /></strong></span><br />
<br />
You can use this preg_replace() syntax for any of the html tags.</p>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1859388405414689578.post-48262483418081033652014-08-14T19:24:00.001+05:302014-08-18T11:01:14.317+05:30htmlentities() and html_entity_decode() in JQuery<span style="color: brown; font-size: small;"><i><b>htmlentities() and html_entity_decode() in JQuery :</b></i></span><br />
<br />
<img alt="htmlentities() and html_entity_decode() in JQuery" src="http://codesignature.com/wp-content/uploads/2012/05/post4.png" style="height: 300px; width: 300px;" /><br />
We are all know about use of htmlentities() in PHP. This function is used to convert all character to HTML entities. both function are used to treat string as a html and HTML as a string.<br />
<br />
<b>For Example :</b><br />
<br />
<span style="color: brown;">
<br />
echo htmlentities("<a href="http://techniqzone.blogspot.in/">TechniqZone</a>");<br />
<br />
?></span><br />
<br />
<b>Output :</b><br />
<br />
<span style="color: #a64d79;"> &lt ;a href=&#39 ;techniqzone.blogspot.in'&#39 ;&gt ;TechniqZone&lt ;/a&gt ; </span><br />
// here semicolons (;) are placed with spaces for display here.<br />
<br />
This is very usefull in many places in php files to display html tags in website. But in javascript/JQuery, pre-defined encode decode function is not available.<br />
<br />
I hereby explained how to use encode and decode of HTML tags in JQuery. Before that need to know the diifference between JQuery.html() and JQuery.text().<br />
<br />
<span style="color: brown;">JQuery.html() - Treat string as HTML.<br />
JQuery.html() - Treat HTML as string.</span><br />
<br />
<b> For Example :</b><br />
<br />
<span style="color: brown;"> $("#techZone").html("<a href=''></a>");<br />
$("#techZone").text("<a href=''></a>");</span><br />
<br />
Okay, now we create encode/decode custom function using JQuery.<br />
<br />
<span style="color: brown;">function htmlentities(str)<br />
{<br />
if(str) // check str is empty or not.<br />
return $("<div />").text(str).html();<br />
else<br />
return 'Argument mis-matched';<br />
}</span><br />
<br />
<b><span style="color: brown;"> htmlentities("</span></b><b><span style="color: brown;"><span style="color: brown;"><a href="http://techniqzone.blogspot.in/">TechniqZone</a></span>");</span></b><br />
<br />
Here create dummy <div> tag and append given string as text, after that take that dummy div text as html content.<br />
<br />
<b>For decode,</b><br />
<br />
<span style="color: brown;">function html_entity_decode(str)<br />
{<br />
if(str) // check str is empty or not.<br />
return $("<div />").html(str).text();<br />
else<br />
return 'Argument mis-matched';<br />
}</span><br />
<br />
<b><span style="color: brown;">html_entity_decode("&lt ;a href=&#39 ;techniqzone.blogspot.in&#39 ;&gt ;TechniqZone&lt ;/a&gt ;");</span></b><br />
// here semicolons (;) are placed with spaces for display here.<br />
<br />
<b>Note : </b>htmlentities and html_entity_decode function are only working with jquery plugin files.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1859388405414689578.post-7226777310428995542014-06-06T19:01:00.001+05:302014-06-06T19:01:26.883+05:30Redirect with HTTP Status Code - PHP<p><em><strong>Redirect with HTTP Status Code - PHP :</strong></em></p>
<p><img alt="Redirect with HTTP Status Code - PHP - TechniqZone" src="http://www.prosoxi.com/wp-content/uploads/2011/04/cdl_capture_2011-04-17-17_-000.jpg" style="height:144px; width:206px" /></p>
<p> </p>
<p>Redirect one url to another url using php is simply run with "header ("Location: redirectURL");" . But redirect with HTTP Status Code is more efficient to optimize for search engines.</p>
<p> Here i will explain about php redirect with http status code. These http status code is common for all php versions.</p>
<p><strong><span style="color:#008080"><?php<br />
function httpRedirect($code,$redirectURL){<br />
static $httpType = array (<br />
100 => "HTTP/1.1 100 Continue",<br />
101 => "HTTP/1.1 101 Switching Protocols",<br />
200 => "HTTP/1.1 200 OK",<br />
201 => "HTTP/1.1 201 Created",<br />
202 => "HTTP/1.1 202 Accepted",<br />
203 => "HTTP/1.1 203 Non-Authoritative Information",<br />
204 => "HTTP/1.1 204 No Content",<br />
205 => "HTTP/1.1 205 Reset Content",<br />
206 => "HTTP/1.1 206 Partial Content",<br />
300 => "HTTP/1.1 300 Multiple Choices",<br />
301 => "HTTP/1.1 301 Moved Permanently",<br />
302 => "HTTP/1.1 302 Found",<br />
303 => "HTTP/1.1 303 See Other",<br />
304 => "HTTP/1.1 304 Not Modified",<br />
305 => "HTTP/1.1 305 Use Proxy",<br />
307 => "HTTP/1.1 307 Temporary Redirect",<br />
400 => "HTTP/1.1 400 Bad Request",<br />
401 => "HTTP/1.1 401 Unauthorized",<br />
402 => "HTTP/1.1 402 Payment Required",<br />
403 => "HTTP/1.1 403 Forbidden",<br />
404 => "HTTP/1.1 404 Not Found",<br />
405 => "HTTP/1.1 405 Method Not Allowed",<br />
406 => "HTTP/1.1 406 Not Acceptable",<br />
407 => "HTTP/1.1 407 Proxy Authentication Required",<br />
408 => "HTTP/1.1 408 Request Time-out",<br />
409 => "HTTP/1.1 409 Conflict",<br />
410 => "HTTP/1.1 410 Gone",<br />
411 => "HTTP/1.1 411 Length Required",<br />
412 => "HTTP/1.1 412 Precondition Failed",<br />
413 => "HTTP/1.1 413 Request Entity Too Large",<br />
414 => "HTTP/1.1 414 Request-URI Too Large",<br />
415 => "HTTP/1.1 415 Unsupported Media Type",<br />
416 => "HTTP/1.1 416 Requested range not satisfiable",<br />
417 => "HTTP/1.1 417 Expectation Failed",<br />
500 => "HTTP/1.1 500 Internal Server Error",<br />
501 => "HTTP/1.1 501 Not Implemented",<br />
502 => "HTTP/1.1 502 Bad Gateway",<br />
503 => "HTTP/1.1 503 Service Unavailable",<br />
504 => "HTTP/1.1 504 Gateway Time-out"<br />
);<br />
header($httpType[$code]);<br />
header ("Location: $redirectURL");<br />
}</span></strong></p>
<p><strong><span style="color:#008080">httpRedirect(301,"http://techniqzone.blogspot.in/");</span></strong></p>
<p><strong><span style="color:#008080">?></span></strong></p>
<p>Normally we do only header("Location: url"), here add header http status before redirect to given url.</p>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1859388405414689578.post-66098034083037888532014-06-05T17:22:00.001+05:302014-06-05T17:22:12.340+05:30PHP Validate Credit Card Number<p><em><strong>PHP Validate Credit Card Number :</strong></em></p>
<p><img alt="PHP Validate Credit Card - TechniqZone" src="http://www.thehiddenwiki.net/wp-content/uploads/2013/08/credit-cards_2007247b.jpg" style="height:167px; width:267px" /></p>
<p> </p>
<p>Now a days , credit card purchase is happened in many websites. The below php function is used to validate the given credit card number in php.</p>
<p><span style="color:#007700; font-family:monospace">function </span><span style="color:#0000bb; font-family:monospace">isCreditCardValid </span><span style="color:#007700; font-family:monospace">( </span><span style="color:#0000bb; font-family:monospace">$number</span><span style="color:#007700; font-family:monospace">, </span><span style="color:#0000bb; font-family:monospace">$cctype </span><span style="color:#007700; font-family:monospace">)<br />
{<br />
if ( !</span><span style="color:#0000bb; font-family:monospace">is_string </span><span style="color:#007700; font-family:monospace">( </span><span style="color:#0000bb; font-family:monospace">$number</span><span style="color:#007700; font-family:monospace">)<br />
|| !</span><span style="color:#0000bb; font-family:monospace">trim </span><span style="color:#007700; font-family:monospace">( </span><span style="color:#0000bb; font-family:monospace">$number </span><span style="color:#007700; font-family:monospace">) )<br />
return </span><span style="color:#0000bb; font-family:monospace">false</span><span style="color:#007700; font-family:monospace">;<br />
<br />
</span><span style="color:#0000bb; font-family:monospace">$ccs </span><span style="color:#007700; font-family:monospace">= array (</span><br />
<br />
<span style="color:#007700; font-family:monospace"> </span><span style="color:#ff8000; font-family:monospace">// Master Card</span><br />
<span style="color:#007700; font-family:monospace"> </span><span style="color:#dd0000; font-family:monospace">'master' </span><span style="color:#007700; font-family:monospace">=> </span><span style="color:#dd0000; font-family:monospace">'/^(5[1-5]{1})(\d{14})$/'</span><span style="color:#007700; font-family:monospace">,</span><br />
<br />
<span style="font-family:monospace"><span style="color:#ff8000"> </span></span><span style="color:#ff8000; font-family:monospace">// American Express </span><br />
<span style="color:#ff8000; font-family:monospace"> </span><span style="color:#dd0000; font-family:monospace">'amex' </span><span style="color:#007700; font-family:monospace">=> </span><span style="color:#dd0000; font-family:monospace">'/^3(4|7)\d{13}$/'</span><span style="color:#007700; font-family:monospace">,</span><br />
<span style="color:#ff8000; font-family:monospace"> </span><br />
<span style="color:#ff8000; font-family:monospace"> </span><span style="color:#ff8000; font-family:monospace">// Discover Card </span><br />
<span style="color:#ff8000; font-family:monospace"> </span><span style="color:#dd0000; font-family:monospace">'discover' </span><span style="color:#007700; font-family:monospace">=> </span><span style="color:#dd0000; font-family:monospace">'/^6(011|22|4|5)(\d{12}|\d{13}|\d{14})$/'</span><span style="color:#007700; font-family:monospace">, </span><br />
<span style="color:#ff8000; font-family:monospace"> </span><br />
<span style="color:#ff8000; font-family:monospace"> </span><span style="color:#ff8000; font-family:monospace">// Visa Card </span><br />
<span style="color:#ff8000; font-family:monospace"> </span><span style="color:#dd0000; font-family:monospace">'visa' </span><span style="color:#007700; font-family:monospace">=> </span><span style="color:#dd0000; font-family:monospace">'/^4(\d{12}|\d{15})$/'</span><span style="color:#007700; font-family:monospace">,</span><br />
<br />
<span style="font-family:monospace"><span style="color:#ff8000"> </span></span><span style="color:#ff8000; font-family:monospace">// Dinners Club</span><span style="color:#ff8000; font-family:monospace"> </span><br />
<span style="color:#ff8000; font-family:monospace"> </span><span style="color:#dd0000; font-family:monospace">'dinners' </span><span style="color:#007700; font-family:monospace">=> </span><span style="color:#dd0000; font-family:monospace">'/^(305|36|38|54|55)(\d{12}|\d{14})$/'</span><span style="color:#007700; font-family:monospace">,</span><br />
<br />
<span style="color:#ff8000; font-family:monospace"> // Carte Blanche </span><span style="color:#ff8000; font-family:monospace"> </span><br />
<span style="color:#ff8000; font-family:monospace"> </span><span style="color:#dd0000; font-family:monospace">'carte' </span><span style="color:#007700; font-family:monospace">=> </span><span style="color:#dd0000; font-family:monospace">'/^(30[0-5]{1})(\d{11})$/'</span><span style="color:#007700; font-family:monospace">, </span><br />
<span style="color:#ff8000; font-family:monospace"> </span><br />
<span style="color:#ff8000; font-family:monospace"> </span><span style="color:#ff8000; font-family:monospace">// enRoute </span><br />
<span style="color:#ff8000; font-family:monospace"> </span><span style="color:#dd0000; font-family:monospace">'enroute' </span><span style="color:#007700; font-family:monospace">=> </span><span style="color:#dd0000; font-family:monospace">'/^2(014|149)\d{11}$/'</span><span style="color:#007700; font-family:monospace">, </span><br />
<span style="color:#ff8000; font-family:monospace"> </span><br />
<span style="color:#ff8000; font-family:monospace"> </span><span style="color:#ff8000; font-family:monospace">// Laser</span><br />
<span style="color:#ff8000; font-family:monospace"> </span><span style="color:#dd0000; font-family:monospace">'laser' </span><span style="color:#007700; font-family:monospace">=> </span><span style="color:#dd0000; font-family:monospace">'/^6(304|706|771|709)(\d{12}|\d{13}|\d{14}'</span><span style="color:#007700; font-family:monospace">.</span><br />
<span style="color:#dd0000; font-family:monospace"> '|d{\15})$/'</span><span style="color:#007700; font-family:monospace">, </span><br />
<span style="font-family:monospace"><span style="color:#ff8000"> </span></span><br />
<span style="color:#ff8000; font-family:monospace"> </span><span style="color:#ff8000; font-family:monospace">// Visa Electron </span><br />
<span style="color:#ff8000; font-family:monospace"> </span><span style="color:#dd0000; font-family:monospace">'visaelec' </span><span style="color:#007700; font-family:monospace">=> </span><span style="color:#dd0000; font-family:monospace">'/^4(17500|917|913|844|508)(\d{10}|\d{12})$/'</span><span style="color:#007700; font-family:monospace">, </span><br />
<span style="color:#ff8000; font-family:monospace"> </span><span style="color:#007700; font-family:monospace">);<br />
<br />
if ( !</span><span style="color:#0000bb; font-family:monospace">is_string </span><span style="color:#007700; font-family:monospace">( </span><span style="color:#0000bb; font-family:monospace">$cctype </span><span style="color:#007700; font-family:monospace">)<br />
|| !</span><span style="color:#0000bb; font-family:monospace">array_key_exists</span><span style="color:#007700; font-family:monospace">( </span><span style="color:#0000bb; font-family:monospace">strtolower </span><span style="color:#007700; font-family:monospace">(</span><span style="color:#0000bb; font-family:monospace">$cctype</span><span style="color:#007700; font-family:monospace">) , </span><span style="color:#0000bb; font-family:monospace">$ccs </span><span style="color:#007700; font-family:monospace">) )<br />
return </span><span style="color:#0000bb; font-family:monospace">false</span><span style="color:#007700; font-family:monospace">;<br />
<br />
return (bool) </span><span style="color:#0000bb; font-family:monospace">preg_match </span><span style="color:#007700; font-family:monospace">( </span><span style="color:#0000bb; font-family:monospace">$ccs</span><span style="color:#007700; font-family:monospace">[</span><span style="color:#0000bb; font-family:monospace">$cctype</span><span style="color:#007700; font-family:monospace">], </span><span style="color:#0000bb; font-family:monospace">$number </span><span style="color:#007700; font-family:monospace">);<br />
} </span></p>
<p> </p>
<p>Example :</p>
<p><?php</p>
<p>if(isCreditCardValid("371449635398431","amex"))<br />
{<br />
echo "Valid";<br />
}<br />
else<br />
{<br />
echo "Not Valid";<br />
}</p>
<p>?></p>
<p> </p>
<p>Here preg_match concept is used to identify the valid credit card number.</p>
<p> </p>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1859388405414689578.post-47957291591743909402014-05-21T18:51:00.001+05:302014-06-07T14:05:07.935+05:30MySQL query to trim particular character from database column fieldMySQL has some default functions to trim particular cahr or whitespaces from all the column field in database rows. MySQL provide four type of methods to trim char.<br />
<b>1. TRIM()<br />
2. TRIM(LEADING)<br />
3. TRIM(BOTH)<br />
4. TRIM(TRAILING)</b><br />
we can use above four methods in select, update and delete queries.<br />
<b>1. TRIM()</b><br />
TRIM() function is used to remove the whitespaces from start and end of the string.<br />
<i>Query : select TRIM( TechniqZone );<br />
Result : TechniqZone</i><br />
This is trim the whitespaces in all the column.<br />
<i>Example : update table_name set field1=TRIM(field1)</i><br />
<b>2. TRIM(LEADING)</b><br />
TRIM(LEADING) function is used to remove the given charecter from the starting postion of the string.<br />
<i>Query : select TRIM(LEADING "'" FROM "TechniqZone'");<br />
Rssult : TechniqZone</i><br />
<br />
This method is remove the single quotes(') from al the column starting postion.<br />
<i>Example : update table_name set field1=TRIM(LEADING "'" FROM field1)</i><br />
<b>3. TRIM(BOTH)</b><br />
TRIM(BOTH) function is used to remove particular charecter from both start and end postion of the string.<br />
<i>Query : select TRIM(BOTH '"' FROM '"TechniqZone"');<br />
Rssult : TechniqZone</i><br />
This is used to remove the double quotes (") from both position.<br />
<i>Example : update table_name set field1=TRIM(BOTH "'" FROM field1)</i><br />
<b>4. TRIM(TRAILING)</b><br />
TRIM(TRAILING) function is used to remove given charecter from end of the string.<br />
<i>Query : select TRIM(TRAILING '.com' FROM "TechniqZone.com");<br />
Rssult : TechniqZone</i><br />
This MySQL query remove the .com from the end of the string.<br />
<i>Example : update table_name set field1=TRIM(TRAILING "xxx" FROM field1)</i><br />
Note : TRIM() and TRIM(BOTH) is same as when we remove whitesapces from database column.<br />
<img alt="MySQL query to trim particular charecter from database column field - TechniqZone" src="http://instaminds.com/wp-content/uploads/2013/06/phpmysql.jpg" style="height: 225px; width: 333px;" />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1859388405414689578.post-36549052388402505532014-05-20T14:49:00.001+05:302014-05-20T15:00:09.847+05:30Check String contains html tags and count of html tags using PHP<img alt="Check String contains html tags and count of html tags using PHP" src="http://api.ning.com/files/0OLa1CvpziEH6f3l5zppT3bQGRQ-XhNB6HA6X9q6JATGrOclE*hrfcNCgZAR51icfSqFau1IOZeFvw9RzSyFH*-GOso2G8IG/html.png" style="height: 261px; width: 467px;" /><br />
Here i will explain how to check the given string contains html tags or not. this function return boolean value.<br />
<code><span style="color: black;"><span style="color: #ff8000;">// Function for check html tag presents</span><br />
<span style="color: #007700;">function </span><span style="color: #0000bb;">hasTags</span><span style="color: #007700;">(</span><span style="color: #0000bb;">$str</span><span style="color: #007700;">){</span><span style="color: #0000bb;"> </span></span></code><br />
<code><span style="color: black;"><span style="color: #0000bb;">$htmlTags </span><span style="color: #007700;">= array(</span><span style="color: #dd0000;">'A' </span><span style="color: #007700;">,</span><span style="color: #dd0000;">'B'</span><span style="color: #007700;">, </span><span style="color: #dd0000;">'BODY'</span><span style="color: #007700;">,</span><span style="color: #dd0000;"> 'BR'</span><span style="color: #007700;">,</span><span style="color: #dd0000;"> 'BUTTON'</span><span style="color: #007700;">, </span><span style="color: #dd0000;">'DIV'</span><span style="color: #007700;">, </span><span style="color: #dd0000;">'FONT'</span><span style="color: #007700;">, </span><span style="color: #dd0000;">'H1'</span><span style="color: #007700;">, </span><span style="color: #dd0000;">'H2'</span><span style="color: #007700;">, </span><span style="color: #dd0000;">'H3'</span><span style="color: #007700;">, </span><span style="color: #dd0000;">'H4'</span><span style="color: #007700;">, </span><span style="color: #dd0000;">'H5'</span><span style="color: #007700;">, </span><span style="color: #dd0000;">'H6'</span><span style="color: #007700;">,</span><span style="color: #dd0000;"> 'IMG'</span><span style="color: #007700;">, </span><span style="color: #dd0000;">'INPUT'</span><span style="color: #007700;">, '</span><span style="color: #dd0000;">TABLE</span><span style="color: #007700;">');</span></span></code><br />
<code><span style="color: black;"><span style="color: #ff8000;">// Here you mention what are the html tags you want to check</span><br /> <span style="color: #007700;">if(</span><span style="color: #0000bb;">preg_match_all</span><span style="color: #007700;">(</span><span style="color: #dd0000;">"~(<\/?)\b("</span><span style="color: #007700;">.</span><span style="color: #0000bb;">implode</span><span style="color: #007700;">(</span><span style="color: #dd0000;">'|'</span><span style="color: #007700;">,</span><span style="color: #0000bb;">$htmlTags</span><span style="color: #007700;">).</span><span style="color: #dd0000;">")\b([^>]*>)~i"</span><span style="color: #007700;">,</span><span style="color: #0000bb;">$str</span><span style="color: #007700;">,</span><span style="color: #0000bb;">$matches</span><span style="color: #007700;">)){<br />
</span><span style="color: #007700;">return </span><span style="color: #0000bb;">TRUE</span><span style="color: #007700;">;<br />
}else{<br />
return </span><span style="color: #0000bb;">FALSE</span><span style="color: #007700;">;<br />
}<br />
} </span></span></code><br />
<code><span style="color: black;"><span style="color: #0000bb;">$str </span><span style="color: #007700;">= </span><span style="color: #dd0000;">'Welcome to <h1><b></b></h1>'</span><span style="color: #007700;">; </span><br />
<br />
<span style="color: #007700;">if(hasTags</span><span style="color: #007700;">(</span><span style="color: #0000bb;">$str</span><span style="color: #007700;">)){<br />
echo </span><span style="color: #dd0000;">'HTML tags Found'</span><span style="color: #007700;">;<br />
}else{<br />
echo </span><span style="color: #dd0000;">'HTML tags not found'</span><span style="color: #007700;">;<br />
} </span></span></code><br />
<br />
If you want to get the present html tags count then consider the below function.<br />
<br />
<code><span style="color: black;"><span style="color: #ff8000;">// Function for check html tag presents</span><br />
<span style="color: #007700;">function </span><span style="color: #0000bb;">hasTags</span><span style="color: #007700;">(</span><span style="color: #0000bb;">$str</span><span style="color: #0000bb;">){<br /> $htmlTags </span><span style="color: #007700;">= array(</span><span style="color: #dd0000;">'A' </span><span style="color: #007700;">,</span><span style="color: #dd0000;">'B'</span><span style="color: #007700;">, </span><span style="color: #dd0000;">'BODY'</span><span style="color: #007700;">,</span><span style="color: #dd0000;"> 'BR'</span><span style="color: #007700;">,</span><span style="color: #dd0000;"> 'BUTTON'</span><span style="color: #007700;">, </span><span style="color: #dd0000;">'DIV'</span><span style="color: #007700;">, </span><span style="color: #dd0000;">'FONT'</span><span style="color: #007700;">, </span><span style="color: #dd0000;">'H1'</span><span style="color: #007700;">, </span><span style="color: #dd0000;">'H2'</span><span style="color: #007700;">, </span><span style="color: #dd0000;">'H3'</span><span style="color: #007700;">, </span><span style="color: #dd0000;">'H4'</span><span style="color: #007700;">, </span><span style="color: #dd0000;">'H5'</span><span style="color: #007700;">, </span><span style="color: #dd0000;">'H6'</span><span style="color: #007700;">,</span><span style="color: #dd0000;"> 'IMG'</span><span style="color: #007700;">, </span><span style="color: #dd0000;">'INPUT'</span><span style="color: #007700;">, '</span><span style="color: #dd0000;">TABLE</span><span style="color: #007700;">');</span></span></code><br />
<br />
<code><span style="color: black;"><span style="color: #007700;"></span></span></code><br />
<code><span style="color: black;"><span style="color: #ff8000;">// Here you mention what are the html tags you want to check</span><br /><span style="color: #007700;">if(</span><span style="color: #0000bb;">preg_match_all</span><span style="color: #007700;">(</span><span style="color: #dd0000;">"~(<\/?)\b("</span><span style="color: #007700;">.</span><span style="color: #0000bb;">implode</span><span style="color: #007700;">(</span><span style="color: #dd0000;">'|'</span><span style="color: #007700;">,</span><span style="color: #0000bb;">$htmlTags</span><span style="color: #007700;">).</span><span style="color: #dd0000;">")\b([^>]*>)~i"</span><span style="color: #007700;">,</span><span style="color: #0000bb;">$str</span><span style="color: #007700;">,</span><span style="color: #0000bb;">$matches</span><span style="color: #007700;">)){<br />
return </span><span style="color: #0000bb;">$matches[1]</span><span style="color: #007700;">;<br />
}else{<br />
return </span><span style="color: #0000bb;">0</span><span style="color: #007700;">;<br />
}<br />
} </span></span></code><br />
<code><span style="color: black;"><span style="color: #0000bb;">$str </span><span style="color: #007700;">= </span><span style="color: #dd0000;">'Welcome to <h1><b></b></h1>'</span><span style="color: #007700;">; </span><br />
<br />
<span style="color: #007700;">echo </span><span style="color: #dd0000;">'Tags Count = '.</span><span style="color: #007700;">hasTags</span><span style="color: #007700;">(</span><span style="color: #0000bb;">$str</span><span style="color: #007700;">); </span></span></code><br />
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1859388405414689578.post-53798281645433895172013-08-25T12:31:00.001+05:302013-10-28T18:50:07.585+05:30Email validation using JavaScript and Jquery<span style="color: #351c75; font-size: large;"><b>Email validation using JavaScript and Jquery</b></span><b><span style="color: #351c75; font-size: large;"> :</span></b><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOmYJrwkpuhVTEqLs-kGIwbdl6OST07ZPAUqj30tQdeYDpBJgxUfeC3Ekk_-Q7eKFjkwSAOBHd1qDYou9hmi7hW0m2D-ISpRnHYvEJgxzEBH06XE_Yo3dLQDgnR-U96NiMNSoUqEzDiAk/s1600/687474703a2f2f6576656e74732e6a71756572792e6f72672f323031322f646576656c6f7065722d73756d6d69742f6173736574732f696d616765732f73756d6d69745f6c6f676f2e706e67.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Email validation in Jquery - TechniqZone" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOmYJrwkpuhVTEqLs-kGIwbdl6OST07ZPAUqj30tQdeYDpBJgxUfeC3Ekk_-Q7eKFjkwSAOBHd1qDYou9hmi7hW0m2D-ISpRnHYvEJgxzEBH06XE_Yo3dLQDgnR-U96NiMNSoUqEzDiAk/s320/687474703a2f2f6576656e74732e6a71756572792e6f72672f323031322f646576656c6f7065722d73756d6d69742f6173736574732f696d616765732f73756d6d69745f6c6f676f2e706e67.png" height="177" title="Email validation in Jquery - TechniqZone" width="320" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: left;">
Here i will explain how to validate email id with JQuery. In JavaScript we can check the email id format only. but in jquery we can check whether we allow or not some of domain names also. First i will explain basic javascript method to validate email id.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>Here is Javascript method :</b></div>
<div style="text-align: left;">
<br /></div><pre class="brush:javascript">
function validateEmail(emailId)
{
var condition = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
return condition.test(emailId);
}
</pre>
In this javascript method only validate the given email id has alphabets and numeric. Here the variable "condition" has the email conditions. that is<br />
<br />
<b>([a-zA-Z0-9_.+-])</b> - is to allow email id username with alphabets and numeric and also _.<br />
<b>@(([a-zA-Z0-9-])</b> - is to allow domail name with alphabets and numeric . and<br />
<b>([a-zA-Z0-9]{2,4})</b> - is to allow last part of the email id i.e., com, in, .. with alphabets and numeric and also it's length should be 2 to 4.<br />
<br />
Now i will explain how to validate email id with JQuery.<br />
<br />
<b>Here is JQuery Method :</b><br />
<br />
<pre class="brush:javascript">
$(document).ready(function() {
$('#submitButton').click(function() {
var emailCon = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
var emailblockCon =/^([\w-\.]+@(?!gmail.com)(?!yahoo.com)([\w-]+\.)+[\w-]{2,4})?$/;
var emailId = $("#mailId").val();
if(emailId == '') {
$("#mailId").val('Email id is Blank.');
error = true
}
else if(!emailCon.test(emailId)) {
$("#mailId").val('Check Your Email id.');
error = true
}
else if(!emailblockCon.test(emailId)) {
$("#mailId").val('gmail and yahoo mail ids not accept.');
error = true
}
if(error == true) {
return false;
}
});
}); </pre>
<br />
In this JQuery method you can check the email format like in javascript . In jquery we validate extra one condition. here we validate the email id domain name also. because some of the website doesnt allow some free email providers domain. so we can also validate it here.<br />
<br />
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1859388405414689578.post-45037443693420720822013-08-19T17:40:00.001+05:302013-08-24T16:31:53.872+05:30PHP - Validate Email Id<div class="mobile-photo">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcV35RtvrfWBI64ZdAW6f0zx4v3d2KQX2J5MPIcj7QJiuI5ITthyqFihu_39-Rtew8sGQMi4Jsjaaa_f1APfpQCPJryliuuxZ37SGrMbaa1BbKHtgB_XhMUL42ghQ6GmpRH5sHPjb9kK4/s1600/email-validation-706418.jpg"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5913801486563635154" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcV35RtvrfWBI64ZdAW6f0zx4v3d2KQX2J5MPIcj7QJiuI5ITthyqFihu_39-Rtew8sGQMi4Jsjaaa_f1APfpQCPJryliuuxZ37SGrMbaa1BbKHtgB_XhMUL42ghQ6GmpRH5sHPjb9kK4/s320/email-validation-706418.jpg" /></a></div>
<br />
<b> PHP - Validate Email Id :</b> <br />
<br />
Here i will explain how to validate email id in php. This is very use full to validate email id in server side. php is used in server so we can validate email id in server side. if you want to validate email id in client side then you can use JavaScript, jquery etc...<br />
<br />
The below example will show you how to validate email id in PHP <br />
<br />
<b> Example :<br /><span style="color: #a64d79;"><?php</span></b><br />
<b><span style="color: #a64d79;">$mailId = "<a href="mailto:xxx@gmail.com">xxx@gmail.com</a>"; // Valid email</span></b><br />
<b><span style="color: #a64d79;">$conditions = '/^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([comco.in])+$/';</span></b><br />
<b><span style="color: #a64d79;">if (preg_match($conditions, $mailId))<br />{<br />echo "Valid Mail Id";<br />}<br />else<br />{<br />echo "Invalid Mail Id";<br />}</span></b><br />
<b><span style="color: #a64d79;">?&gt</span>;</b><br />
<br />
<br />
<br />
<br />
<br />
In the above example "$mailId" having the email id given by user. and "$conditions" having conditions for validate given email id. here i used "preg_match()" predefined php function. this function return boolean value. if the match occurred then it will return true otherwise false.<br />
<br />
The above example print "Valid Mail Id". Here the variable "$conditions" have "com","co","in" conditions only, so it will allow these extension mail id only. and it will validate all allowed special characters only.<br />
<br />
if A<b>$mailId="xxx@gmailo.comnm"</b> then the output is "Invalid Mail Id".Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1859388405414689578.post-72541170906289626922013-08-14T12:31:00.001+05:302013-08-17T11:02:58.948+05:30Create directory with current year and month name - php<div class="mobile-photo">
</div>
<div class="mobile-photo">
<span style="font-size: large;"><span style="color: #a64d79;"><b>Create directory with current <span style="font-size: large;">y</span>ear and <span style="font-size: large;">m</span>onth name - php :</b></span></span></div>
<div class="mobile-photo">
<span style="color: #a64d79;"><b> </b></span><img alt="" border="0" id="BLOGGER_PHOTO_ID_5911866618733117378" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpxsuwr6QFyhyphenhyphenzDhGn2wNHl2xqWxKnmj-mrVohleL7sDZm_wi7HumEqTUlpNShkZWDF8qfdtQT6Bb_l7LGh43_ucAg1c9tRvm_uKfkcMnptpocO_KEviOZP5qytWngEQxdiTE-uGfQcRo/s320/create-folder-709912.png" /></div>
<div style="background-color: white; color: black; font-family: times new roman, new york, times, serif; font-size: 12pt;">
<div>
<br /></div>
<div style="background-color: transparent; color: black; font-family: times new roman,new york,times,serif; font-size: 16px; font-style: normal;">
Here i will explain about how to create folder / directory with the current year and month name. It is very usefull to seperate the uploaded image or file with the particular year and month name.<br /><br /> Here we will use the simple concept to create this. here date() function is used to get current year and month details. <br /><br />
For Example : <br />
<br />
<span style="color: #a64d79;"><b> if (!file_exists("techniq/".date('Y').'/'.date('m'))) {</b></span><br />
<span style="color: #a64d79;"><b> mkdir("techniq/".date('Y').'/'.date('m'), 0777, true);</b></span><br />
<span style="color: #a64d79;"><b> }</b></span><br />
<br />
In the above example three php pre defined function are used. that is file_exists() , date() , mkdir().<br />
<br />
<b>1. file_exists() :- This function is used to check the given path for directory is available or not. It will return bool value. If the file exists then it will return TRUE otherwise FALSE.</b><br />
<b><br /></b>
<b>2. date() :- This function is used to get current timestamp. here i used date('Y'), it will return current year in numeric i.e., 2013. and date('m') return current month in the format of 08.</b><br />
<br />
Note : Read more about date() : http://techniqzone.blogspot.in/2013/07/php-to-get-yesterdayprevious-date.html<br />
<br />
<b>3. mkdir() :- This function is used to create a directory with the give filename or path. here i used 0777 argument for set folder permission for the created directory.</b><br />
<br />
This method is easy to create Folder(directory) with current Year and Month name in php.</div>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1859388405414689578.post-81617499317430982552013-08-13T16:45:00.000+05:302013-08-17T11:03:49.050+05:30Export particular column data from table in phpmyadmin<div class="mobile-photo">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzidjj0P8eFWM4aOdJZkkZQRot385kA9Q6SEekFavg56XQc3d-Atwp6NRV3K-Gkqp0BTO01rbGGj2KEmsFqwVPwoUaiWFytdrByIZq3YLb1YnNm9uNV7QbEQ6GS47c9PP3ErOguI6HBb4/s1600/phpMyAdmin-Logo-798880.png"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5911561198661402066" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzidjj0P8eFWM4aOdJZkkZQRot385kA9Q6SEekFavg56XQc3d-Atwp6NRV3K-Gkqp0BTO01rbGGj2KEmsFqwVPwoUaiWFytdrByIZq3YLb1YnNm9uNV7QbEQ6GS47c9PP3ErOguI6HBb4/s320/phpMyAdmin-Logo-798880.png" /></a></div>
<div style="background-color: white; color: black; font-family: times new roman, new york, times, serif; font-size: 12pt;">
<div style="font-family: times new roman, new york, times, serif; font-size: 12pt;">
<div style="font-family: times new roman, new york, times, serif; font-size: 12pt;">
<br />
<div class="y_msg_container">
<span style="font-size: large;"><span style="color: #a64d79;"><b>Export particular column data from table in phpmyadmin :</b></span></span><br />
<div id="yiv2756446660">
<div>
<div style="background-color: white; color: black; font-family: times new roman, new york, times, serif; font-size: 12pt;">
<div>
<br /></div>
<div style="background-color: transparent; color: black; font-family: times new roman, new york, times, serif; font-size: 16px; font-style: normal;">
Here i will explain how to export particular column data from table. we can store the output in .sql or .csv file. In this method the output data will store in a file with newline (\n) separaters. <br />
<br />
The syntax is :<br />
<br />
<b>SELECT column_name FROM table_name INTO OUTFILE '/opt/lampp/htdocs/fileName.sql'</b><br />
<br />
The above syntax is store the output file in .sql format. you can change the format what you need. In the below example i will make the ooutput file in .csv format.<br />
<br />
Example :<br />
<br />
<b>SELECT second_name FROM employee INTO OUTFILE '/opt/lampp/htdocs/secondName.csv'</b><br />
<br />
Note : Best to download output file with .csv format. because .csv file format import has many advanced option when we import data to db. you can export with CSV, .zip, .gzip, etc... format.<br />
<br /></div>
</div>
</div>
</div>
<br />
<br /></div>
</div>
</div>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1859388405414689578.post-8777955186830081362013-07-31T15:08:00.001+05:302013-07-31T15:23:06.866+05:30PHP - To Check Query Process<div class="mobile-photo">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgai1_2Or6T18rD7OMrofUSY1AtLgJJjrfdDh0CHw2LvJnvt3xBRQjgSRTEXhagJgJDqk2nyLffKa6YluYlf_rUa7JJzRumknrbtnn0tJy_CMlgkbHgrNs6XSQgu_HmHimO7rTvV2LbaM4/s1600/phpmysql-700369.jpeg"><img alt="" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgai1_2Or6T18rD7OMrofUSY1AtLgJJjrfdDh0CHw2LvJnvt3xBRQjgSRTEXhagJgJDqk2nyLffKa6YluYlf_rUa7JJzRumknrbtnn0tJy_CMlgkbHgrNs6XSQgu_HmHimO7rTvV2LbaM4/s320/phpmysql-700369.jpeg" id="BLOGGER_PHOTO_ID_5906711763515076466" /></a></div>
<span style="font-size: large;"><span style="color: #a64d79;"><b>PHP - To Check Query Process:
</b></span></span><br />
<br />
Here i will explain how to check the mysql query processing by using php. This function shows you which threads are running.<br />
<br />
Here i'm using "SHOW FULL PROCESSLIST" mysql command. This command is very useful if you get the "too many connections" error message and want to find out what is going on. The output shows the current running threads process id. You can use that id to kill that process.
<br />
<br />
php program is:
<br />
<br />
<b><span style="color: #a64d79;">mysql_connect("localhost","root",""); // here we set localhost, username and password
</span></b><br />
<b><span style="color: #a64d79;"><br /></span></b>
<b><span style="color: #a64d79;">$q = mysql_query("SHOW FULL PROCESSLIST"); // here we run the mysql query
</span></b><br />
<b><span style="color: #a64d79;"><br /></span></b>
<b><span style="color: #a64d79;">echo "&lt;table border='1'&gt;";
</span></b><br />
<b><span style="color: #a64d79;"><br /></span></b>
<b><span style="color: #a64d79;">while($l = mysql_fetch_row($q) ) {
</span></b><br />
<b><span style="color: #a64d79;">echo "&lt;tr&gt;";
</span></b><br />
<b><span style="color: #a64d79;">foreach($l as $val)
</span></b><br />
<b><span style="color: #a64d79;">echo "&lt;td&gt;$val&nbsp;&lt;/td&gt;";
</span></b><br />
<b><span style="color: #a64d79;">echo "&lt;/tr&gt;";
</span></b><br />
<b><span style="color: #a64d79;"><br /></span></b>
<b><span style="color: #a64d79;">}
</span></b><br />
<b><span style="color: #a64d79;">echo "&lt;/table&gt;";
</span></b><br />
<b><span style="color: #a64d79;"><br /></span></b>
<b><span style="color: #a64d79;">mysql_close();
</span></b><br />
<br />
Note : The "SHOW FULL PROCESSLIST" command only shows you which <br />
threads are running. If you do not use the FULL keyword, only the first 100 characters of each statement are shown in the Info field.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1859388405414689578.post-69829998566351075762013-07-30T15:05:00.001+05:302013-07-30T15:09:42.182+05:30PHP to get yesterday(previous) date<div class="mobile-photo">
</div>
<div class="mobile-photo">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJMDrGmDL85hNrrmutQdjTGwXgrsQPgg5hqpRz8gE0uuy2Uak92IpcnpKnKq9qG6yxc5N8_p1wvucw5jvddqAGDzutRGtSYqc4may9yVc0ndFIFGXtWrXUNqdWunXiF0T1jDe0bnWjGu0/s1600/php-to-get-yesterday-date-techniqzone.blogspot.in-727064.jpg"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5906339931592383810" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJMDrGmDL85hNrrmutQdjTGwXgrsQPgg5hqpRz8gE0uuy2Uak92IpcnpKnKq9qG6yxc5N8_p1wvucw5jvddqAGDzutRGtSYqc4may9yVc0ndFIFGXtWrXUNqdWunXiF0T1jDe0bnWjGu0/s320/php-to-get-yesterday-date-techniqzone.blogspot.in-727064.jpg" /></a></div>
<br />
<span style="font-size: large;"><b><span style="color: #a64d79;">PHP to get yesterday(previous) date:</span></b></span><br />
<br />
Here are some methods to get the previous date using php. i.e.,)
<br />
yesterday date.
<br />
Here date() function is used and "D d-M-Y" format is used, it will
<br />
return the date format like "MON 29-Jul-2013".
<br />
<br />
Let we go to some examples to get the yesterday date in php.
<br />
<b><br /></b>
<b><span style="color: #a64d79;">1. echo date("D d-M-Y", time() - 60 * 60 * 24);
</span></b><br />
<b><span style="color: #a64d79;"><br /></span></b>
<b><span style="color: #a64d79;">2. $pDate = new DateTime();
</span></b><br />
<b><span style="color: #a64d79;">$pDate->add(DateInterval::createFromDateString('yesterday'));
</span></b><br />
<b><span style="color: #a64d79;">echo $pDate->format('D d-M-Y');
</span></b><br />
<b><span style="color: #a64d79;"><br /></span></b>
<b><span style="color: #a64d79;">3. echo date("D d-M-Y", strtotime("yesterday"));
</span></b><br />
<b><span style="color: #a64d79;"><br /></span></b>
<b><span style="color: #a64d79;">4. echo date("D d-M-Y", strtotime('-1 days'));
</span></b><br />
<b><span style="color: #a64d79;"><br /></span></b>
<b><span style="color: #a64d79;">5. echo date('D d-M-Y', time() - 86400);
</span></b><br />
<b><span style="color: #a64d79;"><br /></span></b>
<b><span style="color: #a64d79;">6. echo date("D d-M-Y", mktime(0, 0, 0, date("m") , date("d")-1,date("Y")));
</span></b><br />
<br />
<br />
These all are return the date in same format like "MON 29-Jul-2013";
<br />
<br />
If you want some other date format then consider the below examples.
<br />
<br />
<b><span style="color: #a64d79;">date("D d-M-Y"); // TUE 30-Jul-2013
</span></b><br />
<b><span style="color: #a64d79;">date("F j, Y, g:i a"); // July 30, 2013, 3:10 pm
</span></b><br />
<b><span style="color: #a64d79;">date("m.d.y"); // 07.30.13
</span></b><br />
<b><span style="color: #a64d79;">date("j, n, Y"); // 30, 7, 2013
</span></b><br />
<b><span style="color: #a64d79;">date("Y-m-d H:i:s"); // 2013-07-30 11:22:14
</span></b><br />
<b><span style="color: #a64d79;">date('h-i-s, j-m-y, it is w Day'); // 03-10-41, 30-07-13, 2031
</span></b><br />
<b><span style="color: #a64d79;">2045 2 Tueam13
</span></b><br />
<b><span style="color: #a64d79;">date('\i\t \i\s \t\h\e jS \d\a\y.'); // it is the 30th day.
</span></b><br />
<b><span style="color: #a64d79;">date("D M j G:i:s T Y"); // Tue Jul 30 11:21:03 CEST 2013
</span></b><br />
<b><span style="color: #a64d79;">date('H:m:s \m \i\s\ \m\o\n\t\h'); // 11:07:36 m is month
</span></b><br />
<b><span style="color: #a64d79;">date("H:i:s"); // 11:21:48
</span></b><br />
<b><span style="color: #a64d79;">date("Ymd"); // 20130730
</span></b><br />
<br />
Here you can see the attribute are used in date() function is "D,d,m,y,Y,M,H,m,s,i,a,A".
<br />
so you can modify it as what format you want like "date(D d/m/Y)". etc...
<br />
<br />
If you have any queries comments it. Sorry for my poor english.Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-1859388405414689578.post-38733242762358286112013-07-14T12:32:00.001+05:302013-07-14T12:32:37.778+05:30Increase Import Maximum file size in phpmyadmin<strong>Increase Import Maximum file size in phpmyadmin</strong><br />
<div class="separator" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhA2rHDcMP3jBBADR9y2vhqBWFYUEeuHAqTn76D6Mz8J_syzxKaCgNLxQFjV-q6JuDrAra-rX4-6LMxx4tyA-e6Qu4lBwSqtoJxUGrDhigAo-bWJkhnkfBQH0lbuI5BVWFsXwrWNaMkYQg/s1600/download+%25281%2529.jpg" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" nya="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhA2rHDcMP3jBBADR9y2vhqBWFYUEeuHAqTn76D6Mz8J_syzxKaCgNLxQFjV-q6JuDrAra-rX4-6LMxx4tyA-e6Qu4lBwSqtoJxUGrDhigAo-bWJkhnkfBQH0lbuI5BVWFsXwrWNaMkYQg/s1600/download+%25281%2529.jpg" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br /><br />
<br />
Here are the steps to increase the import file size in phpmyadmin. Usually phpmyadmin allows to import sql files maximum of 2M (i.e 2,048kb). To increase the maximum file size do the following changes in php.ini file.<br />
<br />
<br />
If you are using windows ,the php configuration file can be located in your server (wampp or xampp) -> php folder. <br />
<br />
Find<br />
<strong>upload_max_filesize =2M</strong><br />
in the file,<br />
change the value acording to your need. Here I changed the value to 10M i.e , it allows to import sql files maximum of 10 Mb.<br />
<br />
<strong>upload_max_filesize = 10M</strong><br />
<br />
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1859388405414689578.post-61885652586447243002013-07-14T11:28:00.002+05:302013-07-14T11:28:33.767+05:30Replace MS Word single quotes in PHP<b><span style="color: #a64d79;">Replace MS Word single quotes in PHP:</span></b><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYneRwNLGCcfwPBL_omCBUqOeuDI14IMClp-UaE1ReOWk0EQBZ6pU8RLLoLRRJmnWN3HKe0dOgBBFj-oSivWxKbXC9r8sr_G74hYad9aTeJo5UuklXk4bAy_qtddF3AM_zFbNOtlWAZRw/s1600/images+%25282%2529.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Replace MS Word single quotes in PHP" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYneRwNLGCcfwPBL_omCBUqOeuDI14IMClp-UaE1ReOWk0EQBZ6pU8RLLoLRRJmnWN3HKe0dOgBBFj-oSivWxKbXC9r8sr_G74hYad9aTeJo5UuklXk4bAy_qtddF3AM_zFbNOtlWAZRw/s1600/images+%25282%2529.jpg" title="Replace MS Word single quotes in PHP" /></a></div>
<div style="text-align: center;">
<br /></div>
The following function is used to replace Microsoft-encoded quotes in PHP.<br />
<br />
<b><span style="color: #a64d79;">function replaeQuotes($str) </span></b><br />
<b><span style="color: #a64d79;">{ </span></b><br />
<b><span style="color: #a64d79;"> $str1 = array(chr(145),chr(146), chr(147), chr(148), chr(151)); </span></b><br />
<b><span style="color: #a64d79;"> $str2 = array("'", "'",'"','"','-'); </span></b><br />
<b><span style="color: #a64d79;"> return str_replace($str1, $str2, $str); </span></b><br />
<b><span style="color: #a64d79;">}</span></b><br />
<br />
For Ex:<br />
<br />
In php,<br />
<br />
<b><span style="color: #a64d79;">$str="'This is TechniqZone'-For Developers";</span></b><br />
<b><span style="color: #a64d79;">$clearStr=replaeQuotes($str);</span></b>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1859388405414689578.post-74469291192192942442013-07-14T11:15:00.001+05:302013-07-14T11:15:56.444+05:30Remove MS Word special character symbol in html<b><span style="color: #a64d79; font-size: large;">Remove MS Word special character symbol in html :</span></b><br />
<br />
To remove the MS Word special character in html page or website page you just add the bellow header meta tag in your header field.<br />
<br />
<b><span style="color: #a64d79;"><META http-equiv="Content-type" content="text/html; charset=iso-8859-1"></span></b><br />
<b><span style="color: #a64d79;"><br /></span></b>
Note: In some case the above meta tag will work individually, ie.,) No need to add any other meta tag with this.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7TIRoQeQHMmgdbP995udnRP7hCFZD3alOoCO3Kaf1pB7YB0WJT58kbPbM1mqkhmf17PJ1DuERFpsmywJaVxMd1f0ddeztesMv-1_BQO-wC1aQfN6orY5NsWwIe0ax8gnBJ4_yl8Yioro/s1600/oie_oie_canvas%25281%2529.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Remove MS Word special character symbol in html" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7TIRoQeQHMmgdbP995udnRP7hCFZD3alOoCO3Kaf1pB7YB0WJT58kbPbM1mqkhmf17PJ1DuERFpsmywJaVxMd1f0ddeztesMv-1_BQO-wC1aQfN6orY5NsWwIe0ax8gnBJ4_yl8Yioro/s1600/oie_oie_canvas%25281%2529.png" title="Remove MS Word special character symbol in html" /></a></div>
<div style="text-align: center;">
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1859388405414689578.post-16708385897628880802013-07-11T06:30:00.000+05:302013-07-11T06:30:02.910+05:30PHP Remove HTML tags from a String<b><span style="color: #a64d79; font-size: large;">PHP Remove HTML tags from a String :</span></b><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYneRwNLGCcfwPBL_omCBUqOeuDI14IMClp-UaE1ReOWk0EQBZ6pU8RLLoLRRJmnWN3HKe0dOgBBFj-oSivWxKbXC9r8sr_G74hYad9aTeJo5UuklXk4bAy_qtddF3AM_zFbNOtlWAZRw/s1600/images+%25282%2529.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="PHP Remove HTML tags from a String" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYneRwNLGCcfwPBL_omCBUqOeuDI14IMClp-UaE1ReOWk0EQBZ6pU8RLLoLRRJmnWN3HKe0dOgBBFj-oSivWxKbXC9r8sr_G74hYad9aTeJo5UuklXk4bAy_qtddF3AM_zFbNOtlWAZRw/s1600/images+%25282%2529.jpg" title="PHP Remove HTML tags from a String" /></a></div>
<div style="text-align: center;">
<br /></div>
The following code is used to remove the html tags from string.<br />
<br />
<span style="color: #a64d79;"><b><?php</b></span><br />
<br />
<span style="color: #a64d79;"><b>$input="Hi this is <b>TechniqZone</b>";</b></span><br />
<span style="color: #a64d79;"><b>$text = strip_tags($input, "");</b></span><br />
<span style="color: #a64d79;"><b>echo $text;</b></span><br />
<span style="color: #a64d79;"><b>?></b></span><br />
<br />
Output is <span style="color: #674ea7;">Hi this is TechniqZone.</span><br />
<br />
The above code remove all html tags from string.<br />
<br />
<br />
Here strip_tags() function is used to remove tags from string.<br />
<br />
<span class="type" style="font-family: verdana, arial, helvetica, sans-serif; font-size: 14px;">string</span><span style="background-color: white; font-family: verdana, arial, helvetica, sans-serif; font-size: 14px;"> </span><span class="methodname" style="font-family: verdana, arial, helvetica, sans-serif; font-size: 14px;"><strong>strip_tags</strong></span><span style="background-color: white; font-family: verdana, arial, helvetica, sans-serif; font-size: 14px;"> ( </span><span class="methodparam" style="font-family: verdana, arial, helvetica, sans-serif; font-size: 14px;"><span class="type">string</span> <code class="parameter" style="font-family: Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-style: italic;">$str</code></span><span style="background-color: white; font-family: verdana, arial, helvetica, sans-serif; font-size: 14px;"> [, </span><span class="methodparam" style="font-family: verdana, arial, helvetica, sans-serif; font-size: 14px;"><span class="type">string</span> <code class="parameter" style="font-family: Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-style: italic;">$allowable_tags</code></span><span style="background-color: white; font-family: verdana, arial, helvetica, sans-serif; font-size: 14px;"> ] )</span><br />
<span style="background-color: white; font-family: verdana, arial, helvetica, sans-serif; font-size: 14px;"><br /></span>
<span style="background-color: white; font-size: 14px;"><span style="font-family: verdana, arial, helvetica, sans-serif;"></span></span><br />
<span style="font-family: verdana, arial, helvetica, sans-serif;">$allowable_tags - You can use the optional second parameter to specify tags which should not be stripped.</span><br />
<br />
<br />
<br />
<b><span style="color: #a64d79;"><?php</span></b><br />
<br />
<b><span style="color: #a64d79;">$input="Hi this is lt;a href='http://techniqzone.blogspot.in'><b>TechniqZone</b>lt;/a>";</span></b><br />
<b><span style="color: #a64d79;">$text = strip_tags($input, "<b>");</span></b><br />
<b><span style="color: #a64d79;">echo $text;</span></b><br />
<b><span style="color: #a64d79;">?></span></b><br />
<br />
<br />
Output is<span style="color: #674ea7;"> Hi this is <b>TechniqZone. </b></span><br />
<b><br /></b>
Here i allowed<b> <b></b> tag from string.<br />
<div>
<br /></div>
<br />
<br />
<br />
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1859388405414689578.post-18486503851236459512013-07-11T03:00:00.000+05:302013-07-11T03:00:01.864+05:30Display Current Indian Standard Time using PHP<b><span style="color: #a64d79; font-size: large;">Display Current Indian Standard Time using PHP :</span></b><br />
<div class="separator" style="clear: both; text-align: center;">
<img alt="display indian standard time php" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYneRwNLGCcfwPBL_omCBUqOeuDI14IMClp-UaE1ReOWk0EQBZ6pU8RLLoLRRJmnWN3HKe0dOgBBFj-oSivWxKbXC9r8sr_G74hYad9aTeJo5UuklXk4bAy_qtddF3AM_zFbNOtlWAZRw/s1600/images+%25282%2529.jpg" title="display indian standard time php" /></div>
<div style="text-align: center;">
<b><span style="color: #a64d79; font-size: large;"><br /></span></b></div>
<br />
The following code is used to get the current indian standard time using php.<br />
here the <b>default_timezone_set()</b> function is used to set the country to set the particular time or date of that country.<br />
<br />
<br />
<b><span style="color: #a64d79;"><?php</span></b><br />
<b><span style="color: #a64d79;">date_default_timezone_set('Asia/Calcutta');</span></b><br />
<b><span style="color: #a64d79;">echo date("h:i a");</span></b><br />
<b><span style="color: #a64d79;">?></span></b><br />
<br />
<b>Output of above code is :</b><br />
<br />
<span style="color: #674ea7;"><b>06:40 pm</b></span><br />
<br />
if you want capital letters of am/pm then you just use date("h:i A"). This will return <b><span style="color: #674ea7;">06:40 PM</span></b>.<br />
Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-1859388405414689578.post-79794254412029506642013-07-10T02:00:00.000+05:302013-07-10T02:00:00.930+05:30Php to convert UTC time to local time<b>Php to convert UTC time to local time</b><br />
<div style="text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYneRwNLGCcfwPBL_omCBUqOeuDI14IMClp-UaE1ReOWk0EQBZ6pU8RLLoLRRJmnWN3HKe0dOgBBFj-oSivWxKbXC9r8sr_G74hYad9aTeJo5UuklXk4bAy_qtddF3AM_zFbNOtlWAZRw/s1600/images+%25282%2529.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;"><img alt="Php to convert UTC time to local time" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYneRwNLGCcfwPBL_omCBUqOeuDI14IMClp-UaE1ReOWk0EQBZ6pU8RLLoLRRJmnWN3HKe0dOgBBFj-oSivWxKbXC9r8sr_G74hYad9aTeJo5UuklXk4bAy_qtddF3AM_zFbNOtlWAZRw/s1600/images+%25282%2529.jpg" title="Php to convert UTC time to local time" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
Here is a simple code to convert UTC time to local time in php. The $dateInLocal displays the UTC time as localtime.<br />
<br />
<br />
$time = strtotime($dateInUTC.' UTC');<br />
$dateInLocal = date("Y-m-d H:i:s", $time);<br />
echo $dateInLocal;<br />
<br />
<br />
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1859388405414689578.post-63930909436947410572013-07-09T03:00:00.000+05:302013-07-09T03:00:00.100+05:30Attachment in mail using PHP<b> Attachment in mail using PHP</b><br />
<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYneRwNLGCcfwPBL_omCBUqOeuDI14IMClp-UaE1ReOWk0EQBZ6pU8RLLoLRRJmnWN3HKe0dOgBBFj-oSivWxKbXC9r8sr_G74hYad9aTeJo5UuklXk4bAy_qtddF3AM_zFbNOtlWAZRw/s1600/images+%25282%2529.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYneRwNLGCcfwPBL_omCBUqOeuDI14IMClp-UaE1ReOWk0EQBZ6pU8RLLoLRRJmnWN3HKe0dOgBBFj-oSivWxKbXC9r8sr_G74hYad9aTeJo5UuklXk4bAy_qtddF3AM_zFbNOtlWAZRw/s1600/images+%25282%2529.jpg" /></a><br />
In the previous post, I described HTML content in mails. In this post we can see how attachment in mails can be done using PHP .<br />
<br />
<br />
<br />
<br />
$to = 'youraddress@example.com';<br />
//define the subject of the email<br />
$subject = 'Test email with attachment';<br />
//create a boundary string. It must be unique<br />
//so we use the MD5 algorithm to generate a random hash<br />
$random_hash = md5(date('r', time()));<br />
//define the headers we want passed. Note that they are separated with \r\n<br />
$headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com";<br />
//add boundary string and mime type specification<br />
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";<br />
//read the atachment file contents into a string,<br />
//encode it with MIME base64,<br />
//and split it into smaller chunks<br />
$attachment = chunk_split(base64_encode(file_get_contents('attachment.zip')));<br />
//define the body of the message.<br />
ob_start(); //Turn on output buffering<br />
?><br />
--PHP-mixed-<br />
Content-Type: multipart/alternative; boundary="PHP-alt-"<br />
<br />
--PHP-alt-<br />
Content-Type: text/plain; charset="iso-8859-1"<br />
Content-Transfer-Encoding: 7bit<br />
<br />
Hello World!!!<br />
This is simple text email message.<br />
<br />
--PHP-alt-<br />
Content-Type: text/html; charset="iso-8859-1"<br />
Content-Transfer-Encoding: 7bit<br />
<h1>
<span style="background-color: white; color: #555555; font-family: arial, verdana, sans-serif; font-size: 12px; line-height: 15.59375px;"><a href="http://techniqzone.blogspot.in/">TechniqZone</a> Is Help To Guide Developers issues</span></h1>
<br />
<br />
This is something with <b>HTML</b> formatting.<br />
<br />
--PHP-alt---<br />
<br />
--PHP-mixed-<br />
Content-Type: application/zip; name="attachment.zip"<br />
Content-Transfer-Encoding: base64<br />
Content-Disposition: attachment<br />
<br />
<br />
--PHP-mixed---<br />
<br />
//copy current buffer contents into $message variable and delete current output buffer<br />
$message = ob_get_clean();<br />
//send the email<br />
$mail_sent = @mail( $to, $subject, $message, $headers );<br />
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"<br />
echo $mail_sent ? "Mail sent" : "Mail failed";<br />
?><br />
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1859388405414689578.post-92027061595603587642013-07-08T07:00:00.000+05:302013-07-08T07:00:01.242+05:30PHP to Determine Page Execution Time<b><span style="color: #a64d79; font-size: large;">PHP to Determine Page Execution Time :</span></b><br />
<b><span style="color: #a64d79; font-size: large;"><br /></span></b>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYneRwNLGCcfwPBL_omCBUqOeuDI14IMClp-UaE1ReOWk0EQBZ6pU8RLLoLRRJmnWN3HKe0dOgBBFj-oSivWxKbXC9r8sr_G74hYad9aTeJo5UuklXk4bAy_qtddF3AM_zFbNOtlWAZRw/s1600/images+%25282%2529.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="PHP to Determine Page Execution Time" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYneRwNLGCcfwPBL_omCBUqOeuDI14IMClp-UaE1ReOWk0EQBZ6pU8RLLoLRRJmnWN3HKe0dOgBBFj-oSivWxKbXC9r8sr_G74hYad9aTeJo5UuklXk4bAy_qtddF3AM_zFbNOtlWAZRw/s1600/images+%25282%2529.jpg" title="PHP to Determine Page Execution Time" /></a></div>
<b><span style="color: #a64d79; font-size: large;"><br /></span></b>
<br />
The below code is used to find the php page execution time.<br />
<br />
<br />
Just paste the below code in header portion in php page.<br />
<br />
<b><span style="color: #a64d79;"><?php </span></b><br />
<b><span style="color: #a64d79;"> $time = microtime(); </span></b><br />
<b><span style="color: #a64d79;"> $time = explode(" ",$time); </span></b><br />
<b><span style="color: #a64d79;"> $time = $time[1] + $time[0]; </span></b><br />
<b><span style="color: #a64d79;"> $starttime = $time; </span></b><br />
<b><span style="color: #a64d79;">;?> </span></b><br />
<br />
after the above code you can add other html or php codes.<br />
<br />
and paste the below code in footer page of same php file.<br />
<br />
<b><span style="color: #a64d79;"><?php </span></b><br />
<b><span style="color: #a64d79;"> $time = microtime(); </span></b><br />
<b><span style="color: #a64d79;"> $time = explode(" ",$time); </span></b><br />
<b><span style="color: #a64d79;"> $time = $time[1] + $time[0]; </span></b><br />
<b><span style="color: #a64d79;"> $endtime = $time; </span></b><br />
<b><span style="color: #a64d79;"> $totaltime = ($endtime - $starttime); </span></b><br />
<b><span style="color: #a64d79;"> echo "This page execution time is ".$totaltime." seconds"; </span></b><br />
<b><span style="color: #a64d79;">;?></span></b>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1859388405414689578.post-7899816397959526552013-07-07T18:30:00.000+05:302013-07-07T18:30:06.243+05:30Sending Nice HTML Email with PHP<br />
<b><span style="color: #a64d79; font-size: large;">Sending Nice HTML Email with PHP :</span></b><br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYneRwNLGCcfwPBL_omCBUqOeuDI14IMClp-UaE1ReOWk0EQBZ6pU8RLLoLRRJmnWN3HKe0dOgBBFj-oSivWxKbXC9r8sr_G74hYad9aTeJo5UuklXk4bAy_qtddF3AM_zFbNOtlWAZRw/s1600/images+%25282%2529.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYneRwNLGCcfwPBL_omCBUqOeuDI14IMClp-UaE1ReOWk0EQBZ6pU8RLLoLRRJmnWN3HKe0dOgBBFj-oSivWxKbXC9r8sr_G74hYad9aTeJo5UuklXk4bAy_qtddF3AM_zFbNOtlWAZRw/s1600/images+%25282%2529.jpg" /></a></div>
<br />
<br />
<br />
Everyone wishes to include Html content in their mails. Here is a sample code to send a mail with HTML content. You can edit the HTML content as you prefer.<br />
<br />
<br />
$to = 'sample@example.com';<br />
<br />
$subject = 'Sample HTML content';<br />
<br />
$headers = "From: " . strip_tags($_POST['req-email']) . "\r\n";<br />
$headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n";<br />
$headers .= "CC: susan@example.com\r\n";<br />
$headers .= "MIME-Version: 1.0\r\n";<br />
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";<br />
<br />
$message = '<h1>';<html><body>';</body></html><br />
$message .= '<a href='http://techniqzone.blogspot.in/'>TechniqZone</a> Is Help To Guide Developers issues.';<br />
$message .= '</h1>';<br />
mail($to, $subject, $message, $headers);<br />
<br />
<br />
$message contains HTML content. And the HTML content will be executed in the mail.<br />
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1859388405414689578.post-5231414597447874062013-07-07T18:23:00.002+05:302013-07-07T18:23:37.965+05:30PHP Get Last 12 Months<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYneRwNLGCcfwPBL_omCBUqOeuDI14IMClp-UaE1ReOWk0EQBZ6pU8RLLoLRRJmnWN3HKe0dOgBBFj-oSivWxKbXC9r8sr_G74hYad9aTeJo5UuklXk4bAy_qtddF3AM_zFbNOtlWAZRw/s1600/images+%25282%2529.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYneRwNLGCcfwPBL_omCBUqOeuDI14IMClp-UaE1ReOWk0EQBZ6pU8RLLoLRRJmnWN3HKe0dOgBBFj-oSivWxKbXC9r8sr_G74hYad9aTeJo5UuklXk4bAy_qtddF3AM_zFbNOtlWAZRw/s1600/images+%25282%2529.jpg" /></a></div>
<div style="text-align: center;">
<br /></div>
<b><span style="color: #a64d79; font-size: large;">PHP to get last 12 months : </span></b><br />
<br />
The following coding is used to get previous 12 months by using PHP.<br />
<br />
<br />
<br />
<b><span style="color: #a64d79;"><?php</span></b><br />
<b><span style="color: #a64d79;"><br /></span></b>
<b><span style="color: #a64d79;">for ($t = 1; $t <= 12; $t++) {</span></b><br />
<b><span style="color: #a64d79;"> echo date("F Y m", strtotime( date( 'Y-m-01' )." -$t months"));</span></b><br />
<b><span style="color: #a64d79;"> echo "<br />";</span></b><br />
<b><span style="color: #a64d79;">}</span></b><br />
<b><span style="color: #a64d79;"><br /></span></b>
<b><span style="color: #a64d79;">?></span></b><br />
<br />
<b> Output of this code is :</b><br />
<br />
<b><span style="color: #674ea7;">June 2013 06<br />May 2013 05<br />April 2013 04<br />March 2013 03<br />February 2013 02<br />January 2013 01<br />December 2012 12<br />November 2012 11<br />October 2012 10<br />September 2012 09<br />August 2012 08<br />July 2012 07</span></b><br />
<br />
<br />
Here date "F Y m" is used to make the date format in above format. you can store these dates in arrat also by using below code.<br />
<br />
<br />
<b><span style="color: #a64d79;"><?php</span></b><br />
<b><span style="color: #a64d79;">for ($t = 1; $t <= 12; $t++) {</span></b><br />
<b><span style="color: #a64d79;"> $mnt[]= date("F Y m", strtotime( date( 'Y-m-01' )." -$t months"));</span></b><br />
<b><span style="color: #a64d79;">}</span></b><br />
<b><span style="color: #a64d79;">?></span></b><br />
<br />
<br />
Here $mnt is php array variable with last 12 months.<br />
<br />
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1859388405414689578.post-12748697178490246302013-06-17T02:30:00.000+05:302013-06-17T02:30:02.016+05:30Get all images from folder - php<b><span style="color: #a64d79; font-size: large;">Get all images from folder - php:</span></b><br />
<b><span style="color: #a64d79; font-size: large;"><br /></span></b>
The below code is used to get all images from folder in local system. we can set the condition for file type to read files from particular directory in php.<br />
<br />
<b><span style="color: #a64d79;"><?php</span></b><br />
<b><span style="color: #a64d79;">$imgdir = 'images/'; </span></b><br />
<b><span style="color: #a64d79;">$allowed_types = array('png','jpg','jpeg','gif'); </span></b><br />
<b><span style="color: #a64d79;">$dimg = opendir($imgdir);</span></b><br />
<b><span style="color: #a64d79;">while($imgfile = readdir($dimg))</span></b><br />
<b><span style="color: #a64d79;">{</span></b><br />
<b><span style="color: #a64d79;"> if( in_array(strtolower(substr($imgfile,-3)),$allowed_types) OR</span></b><br />
<b><span style="color: #a64d79;"> in_array(strtolower(substr($imgfile,-4)),$allowed_types) )</span></b><br />
<b><span style="color: #a64d79;">/*If the file is an image add it to the array*/</span></b><br />
<b><span style="color: #a64d79;"> {$a_img[] = $imgfile;}</span></b><br />
<b><span style="color: #a64d79;">}</span></b><br />
<b><span style="color: #a64d79;">echo "<ul>";</span></b><br />
<br />
<b><span style="color: #a64d79;"> $totimg = count($a_img);</span></b><br />
<br />
<b><span style="color: #a64d79;"> for($x=0; $x < $totimg; $x++)</span></b><br />
<b><span style="color: #a64d79;">{</span></b><br />
<b><span style="color: #a64d79;">echo "<li><img src='" . $imgdir . $a_img[$x] . "' /></li>";</span></b><br />
<b><span style="color: #a64d79;">}</span></b><br />
<b><span style="color: #a64d79;">echo "</ul>";</span></b><br />
<br />
<b><span style="color: #a64d79;"><br /></span></b>
<b><span style="color: #a64d79;">?></span></b><br />
<div>
<br /></div>
<div>
<br /></div>
<div>
In the above coe $imgdir is used to pick your directory. $allowed_type is used to set the type of files u allowed from folder to pickup. </div>
<div>
<br /></div>
<div>
opendir() function is used to open your given folder to read it.</div>
<div>
<br /></div>
<div>
readdir() is used to read folder. the while loop is read all files from folder and push the allowed type files in $a_img array.</div>
<div>
<br /></div>
<div>
Now we can print all image name by using for loop or any other method.</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYneRwNLGCcfwPBL_omCBUqOeuDI14IMClp-UaE1ReOWk0EQBZ6pU8RLLoLRRJmnWN3HKe0dOgBBFj-oSivWxKbXC9r8sr_G74hYad9aTeJo5UuklXk4bAy_qtddF3AM_zFbNOtlWAZRw/s1600/images+%25282%2529.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYneRwNLGCcfwPBL_omCBUqOeuDI14IMClp-UaE1ReOWk0EQBZ6pU8RLLoLRRJmnWN3HKe0dOgBBFj-oSivWxKbXC9r8sr_G74hYad9aTeJo5UuklXk4bAy_qtddF3AM_zFbNOtlWAZRw/s1600/images+%25282%2529.jpg" /></a></div>
<div style="text-align: center;">
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1859388405414689578.post-85323980647645452202013-06-16T19:24:00.001+05:302013-06-16T19:24:33.478+05:30Javascript popup window to return value to parent window<b><span style="color: #a64d79; font-size: large;">Javascript popup window to return value to parent window:</span></b><br />
<b><span style="color: #a64d79; font-size: large;"><br /></span></b>
We can pass the values to child window to parent window by using javascript. These passing methodology working with html tags and javascript functions.<br />
<br />
The javascript popup window is used to get the external value like select the region from map etc.<br />
<br />
Follow the below html programs to pass the value from javascript popup window..<br />
<br />
parent.html :<br />
<br />
<span style="color: #a64d79;"><b><html></b></span><br />
<span style="color: #a64d79;"><b><head></b></span><br />
<span style="color: #a64d79;"><b><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"></b></span><br />
<span style="color: #a64d79;"><b><title>Opener</title></b></span><br />
<span style="color: #a64d79;"><b><script type='text/javascript'></b></span><br />
<span style="color: #a64d79;"><b>function valideopenerform(){</b></span><br />
<span style="color: #a64d79;"><b>var popy= window.open('popup.html','popup_form','location=no,menubar=no,status=no,top=50%,left=50%,height=550,width=750')</b></span><br />
<span style="color: #a64d79;"><b>}</b></span><br />
<span style="color: #a64d79;"><b></script></b></span><br />
<span style="color: #a64d79;"><b></head></b></span><br />
<span style="color: #a64d79;"><b><br /></b></span>
<span style="color: #a64d79;"><b><body></b></span><br />
<span style="color: #a64d79;"><b><form name='form1' id='form1' ></b></span><br />
<span style="color: #a64d79;"><b><input type='text' id='text1' name='text1' /></b></span><br />
<span style="color: #a64d79;"><b><input type='button' value='go' onclick='valideopenerform()' /></b></span><br />
<span style="color: #a64d79;"><b></form></b></span><br />
<span style="color: #a64d79;"><b><br /></b></span>
<span style="color: #a64d79;"><b></body></b></span><br />
<span style="color: #a64d79;"><b><br /></b></span>
<span style="color: #a64d79;"><b></html> </b></span><br />
<span style="color: #a64d79;"><b><br /></b></span>
In this first html <b style="color: #a64d79;">valideopenerform() </b>is i used. in this function i called the second html for open as a popup window. and createone text field with the id "text1". i '' return the value to this text field from popup window.<br />
<span style="color: #a64d79;"><b><br /></b></span>
popup.html<br />
<br />
<span style="color: #a64d79;"><b><html></b></span><br />
<span style="color: #a64d79;"><b><head></b></span><br />
<span style="color: #a64d79;"><b><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"></b></span><br />
<span style="color: #a64d79;"><b><title>Opener</title></b></span><br />
<span style="color: #a64d79;"><b><script type='text/javascript'></b></span><br />
<span style="color: #a64d79;"><b>function validepopupform(){</b></span><br />
<span style="color: #a64d79;"><b>window.opener.document.form1.text1.value=document.form2.text2.value;</b></span><br />
<span style="color: #a64d79;"><b>self.close();</b></span><br />
<span style="color: #a64d79;"><b>}</b></span><br />
<span style="color: #a64d79;"><b></script></b></span><br />
<span style="color: #a64d79;"><b><br /></b></span>
<span style="color: #a64d79;"><b></head></b></span><br />
<span style="color: #a64d79;"><b><br /></b></span>
<span style="color: #a64d79;"><b><body></b></span><br />
<span style="color: #a64d79;"><b><form id='form2' name='form2' ></b></span><br />
<span style="color: #a64d79;"><b><input type='text' id='text2' name='text2' /></b></span><br />
<span style="color: #a64d79;"><b><input type='button' value='go' onclick='validepopupform()' /></b></span><br />
<span style="color: #a64d79;"><b></form></b></span><br />
<span style="color: #a64d79;"><b><br /></b></span>
<span style="color: #a64d79;"><b></body></b></span><br />
<span style="color: #a64d79;"><b><br /></b></span>
<br />
<span style="color: #a64d79;"><b></html> </b></span><br />
<div>
<br /></div>
<div>
In this second html i used <b style="color: #a64d79;">validepopupform() </b>to return the value to parent window text field by using text field id(text1).</div>
<div>
<br /></div>
<div>
Now the value passed to the parent window text field.</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHhkboCBzZSZ_xFKo9bpSJv4NIHlowHlQtjEGS7TxU8s2Z5jPZfoziN7QgGLEYE7ML4CfR9_7abjRkaIAJbY1FuqkvG8nTExlVT6VeV8RTOCY4Mtci7fHH_hqMRdoB5ukgPsjoBgoG7w0/s1600/images+%25285%2529.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHhkboCBzZSZ_xFKo9bpSJv4NIHlowHlQtjEGS7TxU8s2Z5jPZfoziN7QgGLEYE7ML4CfR9_7abjRkaIAJbY1FuqkvG8nTExlVT6VeV8RTOCY4Mtci7fHH_hqMRdoB5ukgPsjoBgoG7w0/s1600/images+%25285%2529.jpg" /></a></div>
<div style="text-align: center;">
<br /></div>
Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-1859388405414689578.post-5945228014704109782013-05-26T23:16:00.000+05:302013-06-08T09:52:46.980+05:30Rounding Numbers to ‘N’ Decimal<span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #a64d79; display: inline !important; float: none; font-size: large; font: 13px/18px Verdana, Arial, Helvetica, sans-serif; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><strong>Rounding Numbers to ‘N’ Decimal</strong></span><br />
<br />
<span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; display: inline !important; float: none; font: 13px/18px Verdana, Arial, Helvetica, sans-serif; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; display: inline !important; float: none; font: 13px/18px Verdana, Arial, Helvetica, sans-serif; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="Apple-converted-space"> This</span> will let you round off a number to ‘N’ decimal places. In the below <span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; display: inline !important; float: none; font: 13px/18px Verdana, Arial, Helvetica, sans-serif; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">example we are rounding of a number to 2 decimal places.</span></span></span><br />
<br />
<span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; display: inline !important; float: none; font: 13px/18px Verdana, Arial, Helvetica, sans-serif; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; display: inline !important; float: none; font: 13px/18px Verdana, Arial, Helvetica, sans-serif; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; display: inline !important; float: none; font: 13px/18px Verdana, Arial, Helvetica, sans-serif; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"></span></span></span><pre style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px; word-wrap: break-word;"><span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; display: inline !important; float: none; font: 13px/18px Verdana, Arial, Helvetica, sans-serif; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; display: inline !important; float: none; font: 13px/18px Verdana, Arial, Helvetica, sans-serif; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; display: inline !important; float: none; font: 13px/18px Verdana, Arial, Helvetica, sans-serif; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">var num = 4.56789;</span></span></span></pre>
<span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; display: inline !important; float: none; font: 13px/18px Verdana, Arial, Helvetica, sans-serif; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; display: inline !important; float: none; font: 13px/18px Verdana, Arial, Helvetica, sans-serif; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; display: inline !important; float: none; font: 13px/18px Verdana, Arial, Helvetica, sans-serif; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
<pre style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px; word-wrap: break-word;">alert(num.toFixed(2));</pre>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px; word-wrap: break-word;">
<br /></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px; word-wrap: break-word;">
It will alert as 4.56.</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px; word-wrap: break-word;">
<br /></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px; word-wrap: break-word;">
Another function to display a number upto a length is <span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; display: inline !important; float: none; font: 13px/18px monospace; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">toPrecision(x).</span></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px; word-wrap: break-word;">
<br /></div>
<span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; display: inline !important; float: none; font: 13px/18px monospace; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><pre style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px; word-wrap: break-word;">num = 520.2375;
result = num.toPrecision(4);</pre>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px; word-wrap: break-word;">
alert(result);</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px; word-wrap: break-word;">
<br /></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px; word-wrap: break-word;">
It will display as 520.2.</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px; word-wrap: break-word;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHhkboCBzZSZ_xFKo9bpSJv4NIHlowHlQtjEGS7TxU8s2Z5jPZfoziN7QgGLEYE7ML4CfR9_7abjRkaIAJbY1FuqkvG8nTExlVT6VeV8RTOCY4Mtci7fHH_hqMRdoB5ukgPsjoBgoG7w0/s1600/images+%25285%2529.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHhkboCBzZSZ_xFKo9bpSJv4NIHlowHlQtjEGS7TxU8s2Z5jPZfoziN7QgGLEYE7ML4CfR9_7abjRkaIAJbY1FuqkvG8nTExlVT6VeV8RTOCY4Mtci7fHH_hqMRdoB5ukgPsjoBgoG7w0/s1600/images+%25285%2529.jpg" /></a></div>
<div align="center" style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px; word-wrap: break-word;">
</div>
</span></span></span></span><br />Unknownnoreply@blogger.com0