PHP

Laravel How to pass parameter to Accessor method in model via where condition while query building?

I have a Accessor method in Collection Model getSizesAttribute, which returns array of available sizes eg: [‘S’,’L’], Now I need to get Models with have size ‘S’. like: $collections = $collections->where(‘sizes’,’S’); But sizes is array, could I manipulate this anyhow so that I could check returns only if sizes have…

Read More

March 6th, 2020 Laravel, PHP, SolveIt, Tutorials

List files in directory in Codeigniter a php framework

You can use directory helper of codeigniter. To load helper use $this->load->helper(‘directory’); and use directory_map() function to read the directory path specified in the first parameter and builds an array representation of it and all its contained files. Example: $map = directory_map(‘./mydirectory/’); Note: Paths are almost always relative to your…

Read More

March 6th, 2020 Codeigniter, Interview, PHP, SolveIt, Tutorials

Solved – WordPress Mixed Content Error

I have Multisite wordpress environment and also have SSL enabled for the admin section. But I get lots of “Mixed Content” errors on the admin. As a result many scripts and style sheets in the admin are broken . “https://example.com/wp-includes/js/thickbox/loadingAnimation.gif” Blocked loading mixed active content “https://example.com/wp-content/plugins/capsman/framework/styles/admin.css?ver=1.1” Blocked loading mixed active…

Read More

March 6th, 2020 PHP, SEO, SolveIt, Tutorials, Web Design, Wordpress

This will make your mobile website so fast

This will make your mobile website so fast. (Graphics: Shutterstock / Photoraidz) The mobile optimization of your website has become indispensable in this day and age. But not only the design plays an important role. Long loading times scared users. So you can convince with good performance. In the days of the Mobile First Index, where…

Read More

October 15th, 2018 Articles, Branding, Design, Google API, Interview, Javascript, jQuery, mod_rewrite, News, PHP, SEO, Tech News, Tutorials, Web Design, Wordpress

What is Lorem ipsum and where does it come from?

Where does Lorem ipsum come from? (Graphic: Shutterstock / IrenD) Everybody has already read or even used “Lorem ipsum” somewhere. But where exactly does the phrase come from and what should it mean? “Lorem ipsum dolor sit amet” are probably the most widely used words on the web. But almost no one knows…

Read More

October 7th, 2018 Android, Articles, Branding, Codeigniter, Design, Interview, iOS, Javascript, Linux, Magento 2, News, PHP, SEO, Tech News, Tutorials

Are PDO prepared statements sufficient to prevent SQL injection?

The short answer is NO, PDO prepares will not defend you from all possible SQL-Injection attacks. For certain obscure edge-cases. I’m adapting this answer to talk about PDO… The long answer isn’t so easy. It’s based off an attack demonstrated here. The Attack So, let’s start off by showing the…

Read More

May 2nd, 2018 Amazon Linux, Codeigniter, Databases, Laravel, Linux, MySQL, PHP, Tutorials, Ubuntu

How can you prevent SQL injection in PHP?

By Using prepared statements and parameterized queries. These are SQL statements that are sent to and parsed by the database server separately from any parameters. This way it is impossible for an attacker to inject malicious SQL. You basically have two options to achieve this: Using PDO (for any supported…

Read More

May 2nd, 2018 Articles, Codeigniter, Databases, Laravel, MySQL, PHP, Tutorials

How to change your Laravel site favicon

Remember that Laravel is serving files from the /public directory as root, not the project directory. Setting up the favicon is a two step process: Add this code to your layout page: < link rel=”shortcut icon” href=”{{ asset(‘favicon.ico’) }}” > Then put your favicon in the sites subdirectory \public It…

Read More

February 20th, 2018 Laravel, PHP, Tutorials

How to install Laravel 5.6 + PHP 7.1 with Apache on Ubuntu 16.04

Laravel is a powerful MVC-PHP framework, designed for developers who need a simple and elegant toolkit to create full-featured web applications. Laravel was created by Taylor Otwell. In this guide, we will install Laravel 5.6 on Ubuntu 16.04 and as you might already know Laravel 5.6 depends on PHP 7.1+…

Read More

February 19th, 2018 Databases, Laravel, Linux, MySQL, PHP, Tutorials, Ubuntu

MongoDB for PHP Developers – A Beginner’s Guide

Introduction If you want to create a website using MongoDB and PHP, this article will help you to: Connect to a MongoDB database Save documents in a collection Query documents in a collection Perform range queries Sort documents, update a document, delete one or more documents from a collection What…

Read More

March 15th, 2017 Amazon Linux, Articles, CentOS, Codeigniter, Databases, Linux, MongoDB, MySQL, PHP, Tutorials, Ubuntu

How to pass data from PHP to JavaScript ?

There are actually several approaches to do this. They are as following : Use AJAX to get the data you need from the PHP server. Echo out the data inside the page , and use JavaScript to get the data from DOM. Echo out the data directly to JavaScript inside…

Read More

February 16th, 2017 Javascript, jQuery, PHP

Things you must know before MySQL Interview

What are the HEAP tables in MySQL ? HEAP tables also known as  Memory tables are tables taht present in the memory. When creating a HEAP table in MySql, we needs to specify the TYPE of table as HEAP. These memory tables  have values without data type like “BLOB” or…

Read More

February 16th, 2017 Interview, MySQL, PHP, Tutorials

Installing a LAMP Web Server on Amazon Linux Web Server

To install and start the LAMP web server on Amazon Linux Connect to your instance. To ensure that all of your software packages are up to date, perform a quick software update on your instance. This process may take a few minutes, but it is important to make sure you…

Read More

January 25th, 2017 Amazon EC2, Amazon Linux, Articles, CentOS, Databases, Linux, MySQL, PHP, Tutorials, Ubuntu

Install and Configure mod_rewrite for Apache on CentOS or Amazon EC2 Linux

Introduction Apache’s mod_rewrite can be used to manipulate URLs. It is compiled into the base Apache Web Server. This module provides the ability to manipulate URLs prior to determining the appropriate file or handing off to a script. It can help you, if you want to offer different URLs for…

Read More

January 25th, 2017 Amazon EC2, Amazon Linux, CentOS, mod_rewrite, PHP, Tutorials

Solved – Getting this SQL Error: GROUP BY incompatible with sql_mode=only_full_group_by

MySQL 5.7.5+ changed the way GROUP BY behaved in order to be SQL99 compliant (where in previous versions it was not). There is a good overview of the changes here. Unfortunately, this affects some core queries that Craft uses when fetching elements. The good news is that this has been…

Read More

January 19th, 2017 Amazon EC2, Databases, Linux, MySQL, PHP, SolveIt, Tutorials, Ubuntu

Solved – How can I downgrade from PHP 7 to PHP 5.6 on Ubuntu ?

follow the below instructions you face this situation, you may need to disable the proxy_fcgi apache module: sudo a2dismod proxy_fcgi proxy; sudo service apache2 restart 1. Re-Install PHP 5.6 What worked for me was this guide: http://www.lornajane.net/posts/2016/php-7-0-and-5-6-on-ubuntu Actually is not required to remove php7.0, you can install php5.6 together (…

Read More

January 18th, 2017 Amazon EC2, Linux, PHP, SolveIt, Tutorials, Ubuntu

Solved – Magento 2 Admin URL not found and Loaded Front-end is all messy

Sometimes after installing Magento 2 in Ubuntu, linux or wamp server. Admin url shows 404 error after installing  and frontend design is all messy and css is not linked to it. Error visuals are shown below : To solve this first of all, apply proper permissions, enable apache rewrite_module and…

Read More

December 19th, 2016 Magento 2, PHP

The most useful and bestseller courses on Udemy you should consider

The Complete Web Developer Course 2.0 Learn By Doing – build 25 websites and real mobile apps using HTML, CSS, Javascript, PHP, Python, MySQL and a lot more. It’s most current, in-depth and exciting coding course—to date. Designed for you—no matter where you are in your coding journey—this next-generation web…

Read More

November 29th, 2016 Articles, Interview, Javascript, jQuery, Linux, MySQL, Node.js, PHP, SEO, Wordpress

How to use Database Transactions in Codeigniter ?

In order to use transactions in your database queries. You need to use Codeigniter’s transaction methods provided by db library of Codeigniter. The basic snippet is as follows: $this->db->trans_start(); # Starting Transaction //Do your Stuff Here i.e. Queries you wants to run on database $this->db->trans_complete(); # Completing transaction if($this->db->trans_status() ===…

Read More

August 4th, 2016 Codeigniter, Databases, Interview, PHP

Website PageSpeed: Leverage browser caching

What is browser caching? Every time a browser loads a webpage it has to download all the web files to properly display the page. This includes all the HTML, CSS, javascript and images. Some pages might only consist of a few files and be small in size – maybe a…

Read More

June 28th, 2016 PHP, SEO

Tips To Prevent WordPress Hack – A Guide to Secure WordPress Blog

Recently, some of my wordpress blogs were hacked.  I was so involved in other projects that I didn’t pay much attention to security, which is actually the most important thing here. I have removed some shitty plugins, transferred to another website hosting, tweaked codes and more…Today, I have decided to…

Read More

June 28th, 2016 PHP, Wordpress

Install and configure FFmpeg on Ubuntu, Debian, and Linux Mint and dependencies

This process will provide a install of the latest FFmpeg tools and libraries including several external encoding and decoding libraries (codecs) for supported releases of Ubuntu, Debian, and Linux Mint . Installation of the Dependencies sudo apt-get update sudo apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev \ libsdl1.2-dev libtheora-dev…

Read More

June 1st, 2016 FFmpeg, Linux, PHP

World’s Countries, States and Cities database

There are many Database providers which are charging us for providing the Databases of various types. One of them is very important and useful database is for world’s all countries,State and Cities. Every time when we plan to create a website then we stuck on one point that is how…

Read More

March 26th, 2016 Codeigniter, Databases, MySQL, PHP, SEO

SolveIt – Detect the Domain Name

You will be provided with a fragment of HTML code. Your task is to identify unique potential domain names from the links or URLs which are present in that code fragment. For example, if the link http://kravi.online is present in the markup, you should detect the domain: phpdrill.com. If second-level…

Read More

February 27th, 2016 Javascript, PHP, SolveIt

SolveIt – K-subsequences ( Given a large list of n positive integers, count the number of k-subsequences.)

A k-subsequence is defined as follows: It is a subsequence of consecutive elements. The sum of its elements, s, is evenly divisible by k (i.e.: s % k = 0). Complete a function called kSub with two parameters: an integer, k, and an array of integers, nums, of size n.…

Read More

February 27th, 2016 Javascript, PHP, SolveIt

SolveIt – Find out Maximum Difference in an Array

The maximum difference for a pair of elements in some array a is defined as the largest difference between any a[i] and a[j] where i < j and a[i] < a[j]. Create a Function maxDifference to find the maximum difference from array a. Output Format Your maxDifference function should return…

Read More

February 27th, 2016 Javascript, PHP, SolveIt

PHP Tips and Tricks to make your code simple and faster

There are plenty of tips and tricks that you can use to make your code better, and a few of them are covered below. These tips may help you to make your PHP programming better in various ways. PHP Shorthand If/Else Using Ternary Operators (?:) An important part of programming is…

Read More

February 20th, 2016 PHP

Simple and better ways to optimize MySQL query

MySQL  is very popular choice for database management systems. Which uses the SQL querying language to input and query data. Although SQL queries are simple commands that are very easy to learn and use, but not all queries and MySQL database functions operate with the same efficiency. This becomes very…

Read More

January 13th, 2016 MySQL, PHP

Translates a given mRNA string to a peptide-chain in PHP

We can make a simple tool to translate the mRNA (5′-3′) string to a peptide chain by using PHP. Following class is meant to translate a given mRNA string (from 5′ to 3′) to a peptide-chain (Chain of amino acids). <?php class BioTranscription { function BioTranscription() { $this->amino_acids = array(‘Asp’…

Read More

January 5th, 2016 Interview, PHP, Tutorials

Array vs Object when returning data

Prefer Using Objects when returning large amount of data When returning large data, it can be obvious to use Arrays. But Arrays make poor object-to-object data transfer mechanisms in object-oriented programming. Objects are main focus of  Object-oriented programming and it should be. This means that each array should be converted…

Read More

January 4th, 2016 Codeigniter, Javascript, jQuery, MySQL, PHP