Implement Image Slider With Zero Percent Effort.

Below is the entire code of my image slider.You just need to be copy the entire code and paste it into the php or html file.If you have internet connection on you computer then you don't need to be make any changes on it.All image and js are comes dynamically from server.





<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>phpsollutions.blogspot.com</title>
<style type="text/css" media="screen">
<!--
body { font: 1em "Trebuchet MS", verdana, arial, sans-serif; font-size: 100%; }
input, textarea { font-family: Arial; font-size: 125%; padding: 7px; }
label { display: block; }

.infiniteCarousel {
  width: 395px;
  position: relative;
}

.infiniteCarousel .wrapper {
  width: 315px;
  overflow: auto;
  min-height: 10em;
  margin: 0 40px;
  position: absolute;
  top: 0;
}

.infiniteCarousel ul a img {
  border: 5px solid #000;
  -moz-border-radius: 5px;
  -webkit-border-radius: 5px;
}

.infiniteCarousel .wrapper ul {
  width: 9999px;
  list-style-image:none;
  list-style-position:outside;
  list-style-type:none;
  margin:0;
  padding:0;
  position: absolute;
  top: 0;
}

.infiniteCarousel ul li {
  display:block;
  float:left;
  padding: 10px;
  height: 85px;
  width: 85px;
}

.infiniteCarousel ul li a img {
  display:block;
}

.infiniteCarousel .arrow {
  display: block;
  height: 36px;
  width: 37px;
  background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRQccVTA67GdCzjOzw3oEQyutefSYfCSSuYfEKulXnyXiO0dqmqMR1KVcXYsoh7NLNCktYgL3v4f-JRXR26tnGnpzv7aN40u1IEwiy9z11phAukGAxlNh2fjVcdUdHZs3VAMAV-RxxlIpP/s1600/arrow.png) no-repeat 0 0;
  text-indent: -999px;
  position: absolute;
  top: 37px;
  cursor: pointer;
}

.infiniteCarousel .forward {
  background-position: 0 0;
  right: 0;
}

.infiniteCarousel .back {
  background-position: 0 -72px;
  left: 0;
}

.infiniteCarousel .forward:hover {
  background-position: 0 -36px;
}

.infiniteCarousel .back:hover {
  background-position: 0 -108px;
}



-->
</style>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>


<script type="text/javascript">

$.fn.infiniteCarousel = function () {

    function repeat(str, num) {
        return new Array( num + 1 ).join( str );
    }
 
    return this.each(function () {
        var $wrapper = $('> div', this).css('overflow', 'hidden'),
            $slider = $wrapper.find('> ul'),
            $items = $slider.find('> li'),
            $single = $items.filter(':first'),
           
            singleWidth = $single.outerWidth(),
            visible = Math.ceil($wrapper.innerWidth() / singleWidth), // note: doesn't include padding or border
            currentPage = 1,
            pages = Math.ceil($items.length / visible);           


        // 1. Pad so that 'visible' number will always be seen, otherwise create empty items
        if (($items.length % visible) != 0) {
            $slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));
            $items = $slider.find('> li');
        }

        // 2. Top and tail the list with 'visible' number of items, top has the last section, and tail has the first
        $items.filter(':first').before($items.slice(- visible).clone().addClass('cloned'));
        $items.filter(':last').after($items.slice(0, visible).clone().addClass('cloned'));
        $items = $slider.find('> li'); // reselect
       
        // 3. Set the left position to the first 'real' item
        $wrapper.scrollLeft(singleWidth * visible);
       
        // 4. paging function
        function gotoPage(page) {
            var dir = page < currentPage ? -1 : 1,
                n = Math.abs(currentPage - page),
                left = singleWidth * dir * visible * n;
           
            $wrapper.filter(':not(:animated)').animate({
                scrollLeft : '+=' + left
            }, 500, function () {
                if (page == 0) {
                    $wrapper.scrollLeft(singleWidth * visible * pages);
                    page = pages;
                } else if (page > pages) {
                    $wrapper.scrollLeft(singleWidth * visible);
                    // reset back to start position
                    page = 1;
                }

                currentPage = page;
            });               
           
            return false;
        }
       
        $wrapper.after('<a class="arrow back">&lt;</a><a class="arrow forward">&gt;</a>');
       
        // 5. Bind to the forward and back buttons
        $('a.back', this).click(function () {
            return gotoPage(currentPage - 1);               
        });
       
        $('a.forward', this).click(function () {
            return gotoPage(currentPage + 1);
        });
       
        // create a public interface to move to a specific page
        $(this).bind('goto', function (event, page) {
            gotoPage(page);
        });
    }); 
};

$(document).ready(function () {
  $('.infiniteCarousel').infiniteCarousel();
});
</script>


</head>


<body>
    <h1>Simple Image Slider On phpsollutions.blogspot.com</h1>
   
    <div class="infiniteCarousel">
      <div class="wrapper">
        <ul>
          <li><a href="www.phpsollutions.blogspot.com" title="Salman Ahmad">
          <img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8vuHN3tINXyzDlldb9T28yCNz2DQj_3fUTj4M5XqbAaEG47CTsor6AkKzrGlJjUPsx82Meh_UY8PsEXwOQXO4CFInO4TffsaYJAlFVtiE7T-QeMXmaekO1oKcXPo4KXlnEoFMvDrB1ztH/s1600/image5.jpg" height="75" width="75" alt="Tall Glow" /></a></li>
          <li><a href="www.phpsollutions.blogspot.com" title="Salman Ahmad">
          <img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVdcrxhQ0cmzwVB2Khmyns72b35s79aiMKkGD5tpp_DA5f_J9iwKq51Qn9hJKoy2Kri3AWVLacFCTnoWeJ7yqpE9NntddgeB6kAxdjWt_rnOBX6vy_llMJlCkKwjlfm-bqNkB1QMQaSv5b/s1600/image3.jpg" height="75" width="75" alt="Wet Cab" /></a></li>
          <li><a href="www.phpsollutions.blogspot.com" title="Salman Ahmad">
          <img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbmQUHbz-0C9du8q89SYrXfB2WOOauqNtIgh67F456c8gSICWDKBZLa20ksNef-IUqyuAINvEymmGq1J_dC7JvY1dyqRUAKiOMo6N7Pv6jJ2rznA19ZCpNOVx9fy8qmdoQh9wFYajZlNvs/s1600/image2.jpg" height="75" width="75" alt="Rockefella" /></a></li>
          <li><a href="www.phpsollutions.blogspot.com" title="Salman Ahmad">
          <img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8vuHN3tINXyzDlldb9T28yCNz2DQj_3fUTj4M5XqbAaEG47CTsor6AkKzrGlJjUPsx82Meh_UY8PsEXwOQXO4CFInO4TffsaYJAlFVtiE7T-QeMXmaekO1oKcXPo4KXlnEoFMvDrB1ztH/s1600/image5.jpg" height="75" width="75" alt="Chrysler Reflect" /></a></li>
          <li><a href="www.phpsollutions.blogspot.com" title="Salman Ahmad">
          <img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgagpsmSgRE8EzRt59-xulLIByyRtQXG5zlRkL-qKk0PtMFHSU2_BktS1TNLefGyiEGiqDj2GBOGKqeXmFetPYMKqGs1k-IHS-Y0Pyjjv8sGJMzpuqxBpkfEZp6LETZjAgQOzCNrQsXaRLw/s1600/image4.jpg" height="75" width="75" alt="Chrysler Up" /></a></li>
          <li><a href="www.phpsollutions.blogspot.com" title="Salman Ahmad">
          <img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVdcrxhQ0cmzwVB2Khmyns72b35s79aiMKkGD5tpp_DA5f_J9iwKq51Qn9hJKoy2Kri3AWVLacFCTnoWeJ7yqpE9NntddgeB6kAxdjWt_rnOBX6vy_llMJlCkKwjlfm-bqNkB1QMQaSv5b/s1600/image3.jpg" height="75" width="75" alt="Time Square Awe" /></a></li>
          <li><a href="www.phpsollutions.blogspot.com" title="Salman Ahmad">
          <img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbmQUHbz-0C9du8q89SYrXfB2WOOauqNtIgh67F456c8gSICWDKBZLa20ksNef-IUqyuAINvEymmGq1J_dC7JvY1dyqRUAKiOMo6N7Pv6jJ2rznA19ZCpNOVx9fy8qmdoQh9wFYajZlNvs/s1600/image2.jpg" height="75" width="75" alt="Wonky Buildings" /></a></li>
          <li><a href="www.phpsollutions.blogspot.com" title="Salman Ahmad">
          <img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi19lLKOVy_eb8jcy6UP2v4vEiYLc3eK5m32hbYlaKPQyk5uqsB7D5zK3XhGNTkgBinAlvLRV2QHBvg0Hm80SRQuU9a8FRX6hdwSLigjR2WqRoTwj1_sbnK930vZJFymIq4O00uum-9yS5w/s1600/image1.jpg" height="75" width="75" alt="Leaves of Fall" /></a></li>
        </ul>       
      </div>
    </div>
</body>
</html>


Happy Coding :)

Regards
Salman Ahmad

Steps for Installation and Configure a WAMP Server on your computer

There are times when we are so anxious to jump into creating something new that we forget to cover the basics. For web developers it is important, actually vital, to have the ability to test your projects locally before they go live.
While much of the web relies on a Linux, Apache, MySQL, PHP stack, or LAMP, to power applications and dynamic websites, not everyone codes in a Linux environment.
Those who prefer Windows can still replicate how their code will work by using WAMP to replicate a live web environment right on their own computer with the only difference being substituting the Linux operating system in the stack for Windows.

Obtain a copy of WAMP

Before you do anything you need to download WAMP from http://www.wampserver.com/en/download.php. You will have the  option to choose wither a 32 or 64-bit environment depending upon your computer’s configuration. In addition to Apache, PHP and MySQL this download includes phpMyAdmin and SQLBuddy to better help you manage your databases through web based GUI rather than having to use a terminal interface.

Install the software

Once you have downloaded and uncompressed your WAMP executable you will need to go ahead and launch it to start the installation process.







When you click next you will be asked to accept the license agreement. Since it is a GPL license you are free to do just about anything with it so you can go ahead and accept.
The next step requires you to select the folder where you would like to install your WAMP server. The default will be c:\wamp however you can change this to install the server into any directory or partition you choose.




Chose where to install the software

After you choose your directory you will have the option to setup icons. Once you decide on this click Next and then confirm the installation settings again by clicking Install.
Once the installation runs its course you will be asked to choose your default browser. Internet Explorer is the default choice but you can navigate your way to any other browser of your choosing.


NB – if your Windows firewall pops up at this point make sure to grant Apache access.

The next decision you will have to make is to set the PHP mail parameters. Many people leave this set to the defaults when setting up a testing server on their local computer. If you wish to configure it to connect to your SMTP server you may do so here but unless you plan on testing email capabilities the default entries can be left and all you need to do is click Next.



Setting the SMTP server (optional)
Congratulations, WAMP is now installed on your local computer.

Testing the installation

Now that everything has been installed let’s test everything out.
Using one of the icons you created, or Start –> All Programs –> WampServer –> start WampServer, you can launch the management console. Once opened, it will appear an half circle like icon in the lower right hand corner of your screen .Click on that and you will see a popup list like below.


The WAMP management console

If WAMP is not started go ahead and click Start All Services. If you are not sure whether or not WAMP is running, look for the small green W icon in your toolbar. If it is red, WAMP services are stopped, green means everything is running while orange means some services are running.
Now we want to test to see if everything was installed correctly. In the WAMP management console, click on Localhost. If you see the following screen pop up in your browser then everything is working!



 Now you have successfully installed Wamp server on your local computer.Now you can start to configure you web site in www folder in wamp foder .Suppose you install wamp server in C directory then your path is  c://wamp/www/here_your_site_folder.

Happy Coding :)













What is php and history of php language

 PHP development began in 1994 when the developer Rasmus Lerdorf wrote a series of Common Gateway Interface (CGI) Perl scripts, which he used to maintain his personal homepage. The tools performed tasks such as displaying his résumé and recording his web traffic.He rewrote these scripts in C for performance reasons, extending them to add the ability to work with web forms and to communicate with databases, and called this implementation "Personal Home Page/Forms Interpreter" or PHP/FI. PHP/FI could be used to build simple, dynamic web applications. Lerdorf initially announced the release of PHP/FI as "Personal Home Page Tools (PHP Tools) version 1.0" publicly to accelerate bug location and improve the code, on the comp.infosystems.www.authoring.cgi Usenet discussion group on June 8, 1995. This release already had the basic functionality that PHP has as of 2013. This included Perl-like variables, form handling, and the ability to embed HTML. The syntax resembled that of Perl but was more limited and simpler, although less consistent. A development team began to form and, after months of work and beta testing, officially released PHP/FI 2 in November 1997.

Zeev Suraski and Andi Gutmans rewrote the parser in 1997 and formed the base of PHP 3, changing the language's name to the recursive acronym PHP: Hypertext Preprocessor. Afterward, public testing of PHP 3 began, and the official launch came in June 1998. Suraski and Gutmans then started a new rewrite of PHP's core, producing the Zend Engine in 1999. They also founded Zend Technologies in Ramat Gan, Israel.

On May 22, 2000, PHP 4, powered by the Zend Engine 1.0, was released.As of August 2008 this branch reached version 4.4.9. PHP 4 is no longer under development nor will any security updates be released.

On July 13, 2004, PHP 5 was released, powered by the new Zend Engine II.PHP 5 included new features such as improved support for object-oriented programming, the PHP Data Objects (PDO) extension (which defines a lightweight and consistent interface for accessing databases), and numerous performance enhancements. In 2008 PHP 5 became the only stable version under development. Late static binding had been missing from PHP and was added in version 5.3
A new major version has been under development alongside PHP 5 for several years. This version was originally planned to be released as PHP 6 as a result of its significant changes, which included plans for full Unicode support. However, Unicode support took developers much longer to implement than originally thought, and the decision was made in March 2010 to move the project to a branch, with features still under development moved to trunk.

Changes in the new code include the removal of register_globals, magic quotes, and safe mode.The reason for the removals was that register_globals had opened security holes by intentionally allowing runtime data injection, and the use of magic quotes had an unpredictable nature. Instead, to escape characters, magic quotes may be replaced with the addslashes() function, or more appropriately an escape mechanism specific to the database vendor itself like mysql_real_escape_string() for MySQL. Functions that will be removed in future versions and have been deprecated in PHP 5.3 will produce a warning if used.
Many high-profile open-source projects ceased to support PHP 4 in new code as of February 5, 2008, because of the GoPHP5 initiative, provided by a consortium of PHP developers promoting the transition from PHP 4 to PHP 5.
PHP interpreters are available on both 32-bit and 64-bit operating systems, but on Microsoft Windows the only official distribution is a 32-bit implementation, requiring Windows 32-bit compatibility mode while using Internet Information Services (IIS) on a 64-bit Windows platform. Experimental 64-bit versions of PHP 5.3.0 were briefly available for Microsoft Windows, but have since been removed.

Multiple error display every times using jquery validation

Multiple error is display every times when i click on submit button.

See Below Example:




Solution : In my case i put my form tag between table .Thats why every time when i click on submit button it display error multiple times.


My Html  like below:

<table width="990" border="0" align="center" cellpadding="0" cellspacing="0">


<form name="registeredproduct" id="registeredproduct" method="post"   autocomplete="off" >


<div class="label_text">
              <label for="productgroup">Select product catogry:<span class="red">*</span></label>
              <?php $sqlforgroup = mysql_query("SELECT * FROM category WHERE 1 ORDER BY ord"); ?>
              <select name="productgroup" id="productgroup" class="reg_box" onchange="change_productsubcat(this.value)">
                <option value="">Please Select catogry</option>
                <?php  while($VarSqlGroup = mysql_fetch_array($sqlforgroup)) {?>
                <option value="<?php echo $VarSqlGroup['catogry_code'];?>"><?php echo $VarSqlGroup['cat_name'];?></option>
                <?php }?>
              </select>                
            </div>

</form>
   </table> 





Happy coding :)

Making Auto Fill Text Box In php

Some time you need to make an option of auto fill when user start typing in text box then relavent result could display below of text box in drop-down in php like below Example :














<input type="text" name="producttmfg" id="producttmfg" maxlength="30"  class="reg_box" onkeydown="selectManufacture()">  // User to create text box

<span id="loader" style="display:none;"><img src="images/indicator.gif"></span> // User to display loader
<div id="giveopton"></div>  // User to display result in dropdown


<script type="text/javascript">

/*Below function is call when user start typing in text-box and carry record from the data base and display it in drop-down */



  function selectManufacture(){
$("#giveopton").show();
$("#loader").show();
var manuftre=$("#producttmfg").val();
$.post("getManufacture.php", {manufacturer: manuftre}, 
function(response)
{
if(response!=""){
document.getElementById('giveopton').innerHTML=response;
$("#producttmfgloader").hide();
}
}
); 
}
 
/*Below function is call when user point iten from the drop-down and used to display selected text in text box which is user selected from the drop down*/

$('.suggest_links').live('click', function(){
var current = $(this).attr('id');
current = current.replace('suggest_', '');
current = parseInt(current);
for(i=0;i<=30;i++){
if(i == current){
$("#producttmfg").val($('#suggest_'+i).html());
$("#giveopton").hide();
$('#producttmfg').focus();
break;
}
}
});

/*-Below function is used to hide drop-down when user click rest of drop-down options---------- --*/


$(document).click(function(e) {

var isModalBox = (e.target.id == 'giveopton');

if (!isModalBox) {
$('#giveopton').hide();
}


});

</script>

Below is my php code in getManufacture.php file which is call from the selectManufacture()
function :


<?php
include("database_connection.php");
$manufacture=$_POST['manufacturer'];
$query_select="SELECT * FROM manufacturer where manufacturer like '%".$manufacture."%' order by manufacturer asc limit 30";

$sqlformanufacture = mysql_query($query_select);

if(mysql_num_rows($sqlformanufacture)>0){
$i=1;
while($arr=mysql_fetch_assoc($sqlformanufacture)){
$content.="<li class='suggest_links' id='suggest_".$i."'>".$arr['manufacturer']."</li>";
$i++;
}
echo '<ul>'.$content.'</ul>';
}

?>

Below css is call when user hover on drop-down list :

<style>
#giveopton ul{background:#FFFFFF;color:#FF0033;height:auto; max-height:300px;left:38%;overflow-x:hidden;overflow-y:scroll;position:absolute;top:47%;width:53%;z-index:1000;list-style:none;margin:0px;padding:0px}#giveopton ul li{background:#fff;display:block;color:#000;padding-left:10px}#giveopton ul li:hover{background:#d7d7d7;color:#000;cursor:pointer}
<style>




Disable resize property of text area

When you add textarea input in your html then by default its resize property is enable and its display a resize icon on bottom right side by default See below:

Before adding style :




If you want to remove it then  then you have to be add a style on textarea like below :

style="overflow:auto;resize:none;"

After adding style :

Change image after given time duration

In some situation you have to be required to change image after given time duration .

Suppose a situation you want to display an ad image on a prticular location and you want that after some time it will replace with the next ad image .

 Check this example link http://www.campbase.com/   here display ad on right side after some time

To fulfill this need you need to be just copy the below javascript code and paste it in your file .After minor changement you can use it

*********************************************************************
<script type="text/javascript">

    (function() {
        var rotator = document.getElementById('rotator');  // change to your image ID
        var imageDir = 'images/';                          // change to your images folder
        var delayInSeconds = 1;                            // set number of seconds delay
   
      // list image names
        var images = ['1.png', '2.png', '3.png', '4.png'];
   
        // don't change below this line
        var num = 0;
        var changeImage = function() {
            var len = images.length;
            rotator.src = imageDir + images[num++];
            if (num == len) {
                num = 0;
            }
        };
        setInterval(changeImage, delayInSeconds * 1000);
    })();
</script>

**********************************************************************

Now you will need to place an image tag in which you want to display image like below :

<img src="images/1.png" alt="rotating image" width="400" height="300" id="rotator">

Description :  In the above image tag i give its  id rotator .Now in javascript code you will need to change your image directory path in  var imageDir = 'images/'  variable .Change images with your image directory by given full path , now change after how much time you want to change image in delayInSeconds variable , now next you need to be set your image name in  images = ['1.png', '2.png', '3.png', '4.png'] variable .Change 1.png , 2.png, 3.png, 4.png  with your image name

Please give comment if you have any issue during implementation .

 Happy coding :)



RoutingTechniques in code-igneter

If you are using code-igneter then it have a very nice feature to rewrite your website url using route.php and you can make your site seo friendly very easily.

(1)-Suppose if you want to redirect all link which is start with name page after your base url like  

example :  http://www.xyz.com/page/12

Now i want to redirect this link to my home(This is controller name) controller ,and call function cms_page then i write below code :

$route['page/(:any)'] = "home/cms_page/$1";

Description : Now when i type this url in my browser http://www.xyz.com/page/12 then it will redirect in my home controller and function cms_page

(2)- In some situation suppose you want to redirect all link on a perticular controller but rest of some link you don't want to be redirect .In this see below 

example :

$route['^(?!login|camping|managepages|setting|home)\S*'] = "campground/viewdetail/$1";

Decription :In the above example i want to be redirect all links in viewdetail function in  campground controller.But i don't want to be redirect if url contain above controller name which is display in bold letter .like login ,camping , managepages, setting ,home

http://www.xyz.com/login/check/
http://www.xyz.com/camping /search/
http://www.xyz.com/managepages/findlink/
http://www.xyz.com/setting /adminsetting/
http://www.xyz.com/home/index/

Using above example route code rest of all these links will be redirect on viewdetail in campground controller.





Query to select records from your data base on the bases of latitude and longitude and calculate distance in miles

I have latitude and longitude.Now i need a query to select  all select records from my data base between these two on 100 miles radius. So now i write below query to perform my operation :


Example :

$latitude="27.950898" ;
$longitude= "-82.461517" ;
$radius="100";


function getDataByRadius($latitude, $longitude, $radius = 5  ){

$query= "SELECT pop.* ,( 3959 * acos( cos( radians('".$latitude."') ) * cos( radians( pop.lat_decimal ) ) * cos( radians( pop.long_decimal ) - radians('".$longitude."') ) + sin( radians('".$latitude."') ) * sin( radians( pop.lat_decimal ) ) ) ) AS distance FROM mw_popsite AS pop HAVING distance < '".$radius."'  ORDER BY distance ASC ";

$query_exe= mysql_query($query);    
$data=mysql_fetch_assoc($query_exe);
   
 return $data;


}


Description : In  this function my table name is  "mw_popsite" and i want to select all records which latitude and longitude between given latitude and longitude.So i make this simple function in  which you have to pass three parameter latitude,longitude and radius(This distance is in miles.This is count from the center point of any country on google map ).It will return you all data in array form with it distance (In miles) .

If you have any query regarding this then please comment .


Happy coding :) 




Create direction on google map (By draw straight line straight line)

If you want to display direction on google map to draw a straight line in php code.Then you need to just copy and paste below code .Before copy this you need to be include google map library and make it constructor like below :

$google_maps = new Googlemaps();
$polyline = array();
 $polyline['points'] = array($ad->lat_decimal.','.$ad->long_decimal,$get_lat_long_array[0].','.$get_lat_long_array[1]);
 $google_maps->add_polyline($polyline);



Description: In this we pass an array with the source and destination latitude and longitude with seprate it by ','.
 Example array:
 $polyline['points'] =array(source_latitude,source_longitude,destination_latitude,destination_longitude) 

 

Filter or Remove special charecters or space from string in php

Hello guys if you want to remove all special chareters like (&  # @ % , ' ! )  etc every thing then this post is really helpful for you .

Watch below example  :

My string is like this "Lakeside Landing , RV Resort & Marina" and in my case  i want to remove & , and space with  '-' so i write code like below 

$heading = "Lakeside Landing , RV Resort & Marina";

 $heading= ereg_replace("[^A-Za-z0-9]", "-",$heading)  ;

Output :  Lakeside-Landing---RV-Resort---Marina

In this hyphen is come more than one times .So now again i want to only single '-' .So i write again this code.

 $heading= preg_replace('/-+/', '-', $filter_heading);

Now i return this Output :  Lakeside-Landing-RV-Resort-Marina

Password protect site using htaccess

There is a situation where you want to be protect your site using htaccess that no body can access your site except you .

Step you need to be follow :

Create the Password File

  1. Open a new text file called
    .htpasswd
    Note the period at the beginning of the filename.
  2. Use a password encryption program to create your passwords. Paste the lines into your .htpasswd file and save the file. You will have one line for every username that requires access.
  3. Upload the .htpasswd file to a directory on your Web server that is not live on the Web. In other words, you should not be able to go to http://YOUR_URL/.htpasswd - it should be in a home directory or other location that is secure.

Create the htaccess File

  1. Open a text file called .htaccess Note the period at the beginning of the filename.
  2. Add the following to the file:
     AuthUserFile /path/to/htpasswd/file/.htpasswd
     AuthGroupFile /dev/null
     AuthName "Name of Area"
     AuthType Basic
     require valid-user
     
  3. Change
    /path/to/htpasswd/file/.htpasswd
    to the full path to the .htpasswd file you uploaded in above.
  4. Change "Name of Area" to the name of the site you want to be protected. This is used primarily when you have multiple areas with different protection levels.
  5. Save the file and upload it to the directory you want protected.
  6. Test that the password works by accessing the URL. If your password doesn't work, go back to the encryption programs and encrypt it again. Remember that the username and password will be case-sensitive. If you are not prompted for a password, contact your system administrator to make sure that HTAccess is turned on for your site.

explode() is not working to explode with "br" tag


I am trying to explode "<br>" tag but its not working.My string is below

 3013 Bates Lake Road <br>
 Macolm, AL 36566

*************My PHP Code ******************

$string="3013 Bates Lake Road Macolm, AL 36566";

 $array_string=explode('<br>',$string);

print_r($array_string);

****************Result*******************

Array ( [0] => 3013 Bates Lake Road Macolm, AL 36566 )

*****************************************

*****Use <br/> insted of <br> try this it will given you expected result******

$array_string=explode('<br/>',$string);

 print_r($array_string);

****************Result*******************

Array ( [0] => 3013 Bates Lake Road
            [1] => Macolm, AL 36566
           )

*****************************************

Happy coding :)