How to install LAMP Linux Apache Mysql PHP on ubuntu 14.04 LTS

    To Install LAMP on Ubuntu 14.04 LTS Simply Type these commands Install Apache $: sudo apt-get update $: sudo apt-get install apache2 Install Mysql $: sudo apt-get install mysql-server php5-mysql Secure mysql $: sudo mysql_install_db $: sudo mysql_secure_installation Choose options whatever you need Install PHP $: sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt PHP File Configuration to select from directory $: sudo vi /etc/apache2/mods-enabled/dir.conf and paste DirectoryIndex index.php index.html index.

    How to setup phpmyadmin on website

    To setup phpmyadmin on site upload phpmyadmin from any wamp installation found in www/app directory or you can download phpmyadmin from After uploading create from and go to the directory like this you will be prompted for username and password in this case
    $cfg['Servers'][$i]['auth_type']     = 'cookie';
    if you have to access directly you can add auth_type as
    $cfg['Servers'][$i]['auth_type']     = 'config';
    and add the

    mysql_fetch_array(): supplied argument is not a valid MySQL result resource solved

    To solve the problem of mysql_fetch_array(): supplied argument is not a valid MySQL result resource You can use query like this no resource error then

    = @mysql_query("select pid from portfolio where category=". $cid);
    $pids = array();
    if (
    $count_query) {
      while (
    $count_result = @mysql_fetch_array($count_query)) {
    $pids[] = $count_result['pid'];

    How to remove special characters from string using php?

    To remove special characters from string use preg_replace like this
    = 'this is @ test & Strings';

    $mydata = preg_replace("/[^a-zA-Z0-9s]/", "", $mydata);

    //print $mydata; will output "thisistestStrings"

    How to highlight keywords in search results in php

    You can use the below code with the css to highlight keywords in the search results
    Css Styles:
    <style type="text/css">
    .search_highlight {

    PHP Code to highlight search results
    = <SEARCH KEYWORD>; //Keyword to highlight.
    $searchresults = <RETURNED STRING>; //Result of search.
    preg_replace("|($keywords)|Ui", "<span class='search_highlight'>$1</span>", $searchresults);

    How to detect browser using php

    To detect browser in php follow the steps:
    1. Download the class file Click Here
    2. Create Browser class object and call getBrowser() function.

    include 'Browser.php';
    $getbrowser= new Browser();
    $browser_name = $getbrowser->getBrowser();
    $browser_version = $browser->getVersion();

    //You can use $browser_name and $browser_version in conditions to excute code in specific browsers

    How to increment decrement date in php

    To increment/decrement date in php you can use simple process as follows: <?php $your_date = '2011-05-20'; //You need to increment it by 2 day //Convert to time stamp first $your_date_ts = strtotime($your_date); //Increment By 2 Day $your_date_dt = strtotime('+2 day', $your_date_ts); echo date('Y-m-d', $your_date_dt); //Increment By 2 Week $your_date_tw = strtotime('+2 week', $your_date_ts); echo date('Y-m-d', $your_date_tw); //Similar process is followed for decrement just user -2 day or -2 week in place of +1 day or +1 week //Decrement By 2 Day

    How to create download link in php?

    You can create download link in many ways one of the way is as below: Create a file download.php like below <?php // The file path where the file exists $filepath = "".$_GET['filename'].""; header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); //setting content type of page header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=".basename($filepath )); header("Content-Description: File Transfer"); /

    How do we remove element from array?

    You Can use this function to do so
    function remove_element($arr_content,$arr_value) {

    array_values(array_diff($arr_content, array($arr_value)));


    How to get domain from path ?

    Use the following code
    = fetch_domain_name('');
    $domain; //it will output "facebook"
    function fetch_domain_name($path){
    $check = preg_match("/(.*:\/\/)\w{0,}(.*)\.(.*)/", $path, $output);
    $output[2] = str_replace(".","",$output[2]);