Top Questions

  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Jan 4, 2017

    Easy Multiple Image Using Codeigniter.

    if($_FILES['filename']['name']!='')
     {
           $image=array();
           $counts = count($_FILES['filename']['name']);
           $config['upload_path'] = APPPATH.'uploads/'; //create upload folder in application
                                                        // Give permission -R 777 to upload folder 
           $config['allowed_types'] = '*';
           $files = $_FILES;
           for($i=0; $i<$counts; $i  )
            {       
               if($_FILES['filename']['name'][$i]!='')
     { 
           $_FILES['filename']['name']= time().$files['filename']['name'][$i];
           $_FILES['filename']['type']= $files['filename']['type'][$i];
           $_FILES['filename']['tmp_name']= $files['filename']['tmp_name'][$i];
           $_FILES['filename']['error']= $files['filename']['error'][$i];
           $_FILES['filename']['size']= $files['filename']['size'][$i];
           $this->load->library('upload', $config);
           $this->upload->initialize($config);
           $upload= $this->upload->do_upload('familypicture');
           if($upload){
          $uu=$this->upload->data();
                $image[] =$uu['file_name'];
       }
             }
             }
       $fileToUpload = implode('|',$image);
    }
     
  • 5.11 Years

    • Category : Wordpress
    • Location : Mohali
    • Posted On : Aug 14, 2015

    After wordpress login redirect page but not refresh so please try to add these lines in the top of the your wordpress theme file like header.php or wp-config.php https://www.youtube.com/watch?v=ItTjUrTZ_JE

    <?php
    str = "Hello world. It's a beautiful day.";
    print_r (explode(" "$str));
    ?>
    

    1 Answers

    View More
  • 2.9 Years

    • Category : Wordpress
    • Location : Chandigarh
    • Posted On : Apr 1, 2016

    Upload multiple video file and store its in database using this code.

    <?php
    $server_url="http://".$_SERVER['SERVER_NAME'].dirname($_SERVER["REQUEST_URI"].'?').'/';
    $path = preg_replace('/wp-content.*$/','',__DIR__);
    $path = preg_replace('/wp-content(?!.*wp-content).*/','',__DIR__);
    include($path.'wp-load.php');
    /******Database Connect end*******/
    if(isset($_POST['add']))
    {
    $_FILES["fileToUpload"]["name"];
    if ( ! function_exists( 'wp_handle_upload' ) ) {
    require_once( ABSPATH . 'wp-admin/includes/file.php' ); }
    $upload_overrides = array( 'test_form' => false );
     $files = $_FILES["fileToUpload"]; 
        foreach ($files['name'] as $key => $value) {           
                if ($files['name'][$key]) {
                    $file = array(
                        'name' => $files['name'][$key],
                        'type' => $files['type'][$key],
                        'tmp_name' => $files['tmp_name'][$key],
                        'error' => $files['error'][$key],
                        'size' => $files['size'][$key]
                    );
    
                   $_name = $file['name'];
                   $f_name =  explode('.', $_name);
                    $rand = rand(0000,9999);
                   $addname = $f_name['0'].$rand;
                   $total_name = $addname."." .$f_name['1'];
    
                  $insertname[] = $total_name;
    
    
    
                   $file_s = array( 'name' =>  $total_name,
                        'type' => $files['type'][$key],
                        'tmp_name' => $files['tmp_name'][$key],
                        'error' => $files['error'][$key],
                        'size' => $files['size'][$key]
                    );
    
    
    
    
                 
    
                    
                        $newupload = wp_handle_upload($file_s,$upload_overrides);
                      $patoooooooooh[] = $newupload['url'];
                   
                }
            }
    $nname=implode("&",$patoooooooooh);
    mysql_query("insert table_name (`column_name`) values ('$nname')");
    }
    ?>
    /*****Php Code end and html start*****/
    <form class="form-horizontal" method="post" enctype="multipart/form-data">
    <input type="file" name="fileToUpload[]" id="fileToUpload" class="add_file">
    <div class="demo">
    </div>
    <button name="add" type="submit">Add</button>
    </form>
    /********Html End & jquery Start**************/
    
    <script>
    $(document).ready(function() {
    // $('.add_field_button').keyup(function(e){
      var rand=Math.random();
    $(document).on('change','.add_file',function(e){
      //on add input button click
            e.preventDefault();
                $('.demo').append("<div class='sas'><br/><input type='file' name='fileToUpload[]' class='add_file' ><a href='#' class='remove_field'><i class='fa fa-trash-o'></i></a></div>"); //add input box
        });
      $('.demo').on('click', '.remove_field', function(e) {
        $(this).closest('.sas').remove();
      return false;
    });
    });
    </script>
  • 5.11 Years

    • Category : Php
    • Location : Mohali
    • Posted On : Sep 15, 2016

    fix “Headers already sent” error in PHP

    The very quick fix for your problem will be to add

    ob_start();
    as the very first thing in your script if you only need it in this one script. If you need it in all your scripts add it as the very first thing in your header.php file.
  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Jan 7, 2016
    if(isset($_GET['mintime']) && isset($_GET['maxtime'])){
        $extraconditionsa = $extraconditionsa ."and TIME_FORMAT (
       str_to_date (
           replace (hour,':',''),'%H%i'),'%H:%i') between '{$_GET['mintime']}' AND '{$_GET['maxtime']}'";
    }
    
    // mysql:How do I check if a column is empty or null in mysql
    SELECT * FROM table_name WHERE NULLIF(some_col, '') IS NULL;

     

  • 5.11 Years

    • Category : Php
    • Location : Mohali
    • Posted On : Jul 2, 2016

    When you’re using a sophisticated design, CSS files can quickly become very long, and takes time to load. I have compiled interresting ways of compressing CSS files by using PHP.

    (1.)
    <link rel="stylesheet" type="text/css" media="screen" href="/style.css.php"/>
    Once you successfully rename your css files, edit it and add the following code at the beginning of the file:
    <?php if(extension_loaded('zlib')){ob_start('ob_gzhandler');} header("Content-type: text/css"); ?>
     

    2 Answers

    View More
  • 5.11 Years

    • Category : Php
    • Location : Mohali
    • Posted On : Aug 14, 2015
    array(6) { 
    [0]=> string(0) "" 
    [1]=> string(21) " Subject Hello World " 
    [2]=> string(57) " Bonjour se jserais base sdf sdf sd f sqdf qsfd " 
    [3]=> string(22) " martial@gironde.com2 " 
    [4]=> string(12) " hello byee " 
    [5]=> string(11) " loul fund " } 
    
  • 2.9 Years

    • Category : Jquery
    • Location : Chandigarh
    • Posted On : Mar 22, 2016

    You can Create textarea into a rich content/text editor using jQuery.

    /***Footer part***/
    <script type="text/javascript" src="http://js.nicedit.com/nicEdit-latest.js"></script>
    <script type="text/javascript">
            bkLib.onDomLoaded(function() { nicEditors.allTextAreas() }); // convert all text areas to rich text editor on that page
    
            bkLib.onDomLoaded(function() {
                 new nicEditor().panelInstance('area1');
            }); // convert text area with id area1 to rich text editor.
    
            bkLib.onDomLoaded(function() {
                 new nicEditor({fullPanel : true}).panelInstance('area2');
            }); // convert text area with id area2 to rich text editor with full panel.
    </script>
    /***HTML PART***/
    <!DOCTYPE html>
    <html>
    <head>
      <title>How to Create textarea into a rich content/text editor using jQuery</title>  
     
      <script type="text/javascript">
    //<![CDATA[
      bkLib.onDomLoaded(function() {
            new nicEditor({maxHeight : 200}).panelInstance('area');
            new nicEditor({fullPanel : true,maxHeight : 200}).panelInstance('area1');
      });
      //]]>
      </script>
    </head>
    <body>
    <h4>How to Create textarea into a rich content/text editor using jQuery</h4>
    <div id="sample">
      <h4>Simple textarea</h4>  
      <textarea name="area" id="area" style="width:70%;height:200px;">
           Some Initial Content was in this textarea
      </textarea>
      <h4>textarea with complete panel</h4>
      <textarea name="area1" id="area1" style="width:70%;height:200px;">
           Some Initial Content was in this textarea
      </textarea>
    </div>
    </body>
    </html>
  • 5.11 Years

    • Category : Wordpress
    • Location : Mohali
    • Posted On : Feb 22, 2018

    This action hook allows you to access data for a new user immediately after they are added to the database. The user id is passed to hook as an argument.

    add_action( 'user_register', 'eddpremium_register_fields_save');
    add_action( 'profile_update', 'eddpremium_register_fields_save');
    
    function eddpremium_register_fields_save($user_id) {
    	$u = new WP_User($user_id);
    
    	// Remove role
    	$u->remove_role( 'subscriber' );
    
    	// Add role
    	$u->add_role( 'author' );
    }
     
  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Jun 2, 2016

    Get last week start and end date in php

    $previous_week = strtotime("-1 week  1 day");
    
    $start_week = strtotime("last sunday midnight",$previous_week);
    $end_week = strtotime("next saturday",$start_week);
    
    $start_week = date("Y-m-d",$start_week);
    $end_week = date("Y-m-d",$end_week);
    
    echo $start_week.' '.$end_week ;