wonderphp

Some wonder in PHP


wonderphp

  • Install Spark IM client on Linux

    Install Spark IM client on Linux

    Make sure you should install JAVA before proceeding Spark installation because it’s mandatory to run Spark. # Checking JAVA Version # $ java -version java version “1.7.0_95” OpenJDK Runtime Environment (IcedTea 2.6.4) (7u95-2.6.4-0ubuntu0.14.04.1) OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode) # Download Spark Archive file # $ sudo wget http://download.igniterealtime.org/spark/spark_2_7_6.tar.gz # Extract Spark Archive… Continue reading

  • open new window popup using javascript

    <script> function popupW() { window.open(‘http://google.com&#8217;,’banco’,’toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no’); return true; } popupW(); </script> Continue reading

  • how to make word-break

    white-space: pre-wrap; /* css-3 */ white-space: -moz-pre-wrap; /* Mozilla, since 1999 */ white-space: -pre-wrap; /* Opera 4-6 */ white-space: -o-pre-wrap; /* Opera 7 */ word-wrap: break-word; /* Internet Explorer 5.5+ */ width:200px; Continue reading

  • Add recurring task php

    <?php $startDate = $postData[‘start_date’]; $endDate = $postData[‘end_date’]; $endDate = date(“Y-m-d”, strtotime($endDate . ” +1 day”)); /* For weekly schedule * frequency_id: *      ‘1’ => ‘Daily’, *      ‘2’ => ‘alternative day’, *      —-Every——– *      ‘3’ => ‘Monday’, *      ‘4’ => ‘Tuesday’, *      ‘5’ => ‘Wednesday’, *      ‘6’ => ‘Thursday’, *      ‘7’ => ‘Friday’, *      ‘8’ =>… Continue reading

  • phpmyadmin not working after updating php

    Create a link in /var/www like this: sudo ln -s /usr/share/phpmyadmin /var/www/ Note: since 14.04 you may want to use /var/www/html/ instead of /var/www/ (same for php 5) If thats not working for you, you need to include phpmyadmin inside apache configuration. Open apache.conf using your favorite editor, mine is vim 🙂 sudo vim /etc/apache2/apache2.conf… Continue reading

  • How to check an Ajax request in cakephp?

    You need to enable the RequestHandler component var $components = array(‘RequestHandler’); Then you check if its an ajax request in your controllers with: $this->ResquestHandler->isAjax() You can find more information about the RequestHandler component here ALSO, Depends on the version of cake. 1.3.x: $this->ResquestHandler->isAjax(); 2.x $this->request->is(‘ajax’); Continue reading

  • Increment date by any number using js

    This is the function to do so: function increment_date(date,increment) { var dateString = date; var myDate = new Date(dateString); myDate.setDate(myDate.getDate() + increment); var y = myDate.getFullYear(), m = myDate.getMonth() + 1, // january is month 0 in javascript d = myDate.getDate(); var pad = function(val) { var str = val.toString(); return (str.length < 2) ?… Continue reading

  • Reset the password in drupal 7

    If you forgot the password of your drupal admin then dont worry, just follow some steps given here: add following code in root index.php file on the top define(‘DRUPAL_ROOT’, getcwd()); require_once DRUPAL_ROOT . ‘/includes/bootstrap.inc’; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); require_once ‘includes/password.inc’; echo user_hash_password(‘your-new-password’); die(); now copy this password and update in your database. Have a fun   Continue reading

  • Get current weeks record from mysql

    Your date field must of datetime type and sql query will be like : select * from table_name where yearweek(DATE(field_name), 1) = yearweek(curdate(), 1) Continue reading

  • Validate image with dimension

    HTML CODE: <input type=”file” required=”required” class=”file” id=”category_image” error=”error” name=”category_image”> JAVA SCRIPT: $(‘#CategoryEditForm’).validate({ errorElement: ‘div’, errorClass: ‘help-block’, focusInvalid: false, rules: { “category_image”: { extension: “png|jpg|gif|jpeg|bmp” } }, messages: { “category_image”: { extension: “This field can accept images only!” } }, invalidHandler: function (event, validator) { //display error alert on form submit $(‘.alert-danger’, $(‘.login-form’)).show(); }, highlight: function… Continue reading

About Me

A seasoned web developer with over 14 years of experience, has honed a craft across a variety of frameworks and platforms.

Newsletter