Posted on November 24th, 2015 by Abani Meher
This tip demonstrates how to log WordPress queries and query execution time. Step -1: Add following line in wp-config.php file. define(‘SAVEQUERIES’, true); Step – 2: In footer.php of the theme file or in any other file where debugging the query is needed, add code to write the queries to a file. if […]
Posted on November 24th, 2015 by Satheeskumar A
I have been learning Zend Framework2 for quite some time and on my sample application, I have to use different layouts for different user_roles. Though its quite possible to change the layout in the controller action as $this->layout(‘name_of_layout’); where name_of_layout is the name defined in the template_path_stack in the module_config.php. But I feel its eating […]
Posted on November 24th, 2015 by SAMBIT MISHRA
Friends, here I am going to share an interesting thing which I faced recently. In PHP, everyone knows to establish a mysql connection we use (This is the standard) <?php mysql_connect(‘HOST_NAME’, ‘USER_NAME’, ‘PASSWORD’);\* Using MYSQL extnsion *\ /* OR */ mysqli_connect(‘HOST_NAME’, ‘USER_NAME’, ‘PASSWORD’);\* Using MYSQLi extnsion *\ ?> Presently, everyone is using Stored Procedures and […]
Posted on November 23rd, 2015 by Satheeskumar A
I guess most of the users of Symfony2/Zend2 would have used various list of commands for your bundle/module with your app, it may be for installing web assets or generating entity classes for your propel/Doctrine ORM etc.. In my application, we had to start with a new module which doesnt have any pre-defined data in […]
Posted on November 23rd, 2015 by Tapan Pati
The new features in cucumber BDD for rails have been released by its developer, now ‘web_step.rb’ is no longer required. Sounds crazy? Sorry friends,first let me introduce what a web_steps.rb in cucumber is.. IN previous version of cucumber this web_steps.rb file was used for defining some basic functions so that pending cases outcome of cucumber […]
Posted on November 23rd, 2015 by Sujata Mohanty
Using Shell command we can run a PHP script known as child process inside another PHP script known as Parent process without allowing the parent process to wait for the completion of the child process. This is mostly useful for running crons in background where the parent process calling the cron will not wait for […]
Posted on November 23rd, 2015 by Sandeep Saurabh
For creating a module in joomla we need two types of file. – PHP Scripts for business logic. – XML File for installing the Module and providing any default or administrative value to business logic codes. Other CSS and image files can also be included but these are optional according to the need. Easy Steps […]
Posted on November 23rd, 2015 by Supriti Panda
While working with a FLEX-PHP project, I went through an experience which I would like to share. In the project the front end is in FLEX, and the backend part is handled by PHP. This works fine in the local system, but when it is moved to the live server, the file upload functionality doesn’t […]
Posted on November 23rd, 2015 by Shashi Kumar
A site can be generated quickly by using “FileMaker PHP Site Assistant”. It automatically creates a series of PHP pages. The PHP Site Assistant is included in FileMaker Server 9 and its advanced version. Steps for creating a Website 1. First check the option “custom web publishing with php” must be enabled. It is in […]
Posted on November 23rd, 2015 by Sarita Kund
Recently i came across a requirement to convert a wide range of file formats (.doc, docx, .xls, .rtf , .odt, .ods, .ppt etc.) to pdf file in PHP. I found a very good utility to do this, which i would like to share with you all. Note: You need to have OpenOffice and unoconv installed […]
Posted on November 23rd, 2015 by Jyotirmaya Dehury
If we pass the search text directly as entered by user to FileMaker API function while searching, then the search will support the wildcard characters like *, @ etc by default. So to disable the wildcard characters always escape the wildcard characters before using them in the search text and for exact match pass the […]
Posted on November 23rd, 2015 by Saubhagya Swain
While connecting PHP 5.3.5 with Filemaker you may get some Deprecated and Strict Standards errors. Also when you want to connect with Filemaker server database and fetch data you will notice the code will be unable to return any data. It will return an Unknown error. These problem occur because of PHP 5.3.5 no more […]
Posted on November 23rd, 2015 by Swarup Sahu
We generally validate recordse before saving them to database. Most of the times for some fields, some validations are defined in the Filemaker database itself. As long as data passes the validation defined in the Filemaker database, it will thtrow error while saving the data. So we need to check whether the data passes the validation […]
Posted on November 23rd, 2015 by Swarup Sahu
We know we can get value list from a layout with help of getValueList() method. But it has a drawback, let me explain it here: -This method returns value list in an array from the first field. It does not bother about whether second field is associted with the value list or not. -And also […]
Posted on November 23rd, 2015 by Chittaranjan Pattnaik
AWS (Amazon Web Services) provides EC2 instance for its users which can be used as a webserver and on cloud. Users has the flexibility to choose what operating system and which environment they want to use for their web server. For one of our project the client has selected SUSE linux as the EC2 instance […]
Posted on November 23rd, 2015 by ATUL KUMAR
OpenInviter is an open source free import contact script to get email contacts of the particular user from almost all major email service providers like aol, gmail, yahoo mail, msn hotmail etc. The script is written in PHP and can be downloaded from here. The pre-requirements are common but important. The server will need to […]
Posted on November 23rd, 2015 by Chandana Das
If you want to programmatically send images in your email by embedding them in the body of the email , phpMailer() function is what you are looking for. Usage of the function phpMailer(): AddEmbeddedImage ($path=”path“, $cid=”cid“, $name = “”, $encoding =”base 64“,$type=”application/octet-stream“) After this, you need to reference it in the email body <img src=”cid:cid” […]
Posted on November 23rd, 2015 by Subranil Dalal
I recently found that PHP doesn’t have an inbuilt function for conversion of time/datebetween multiple time zones and neither could I find a third-party function for the purpose. However, I did find the PEAR class which has inbuilt support for multiple time-zones but it cannot be used by “including” itself in the php page. PEAR […]
Posted on November 23rd, 2015 by Abinash Grahacharya
Normally you can find out if a particular file exists on the server by calling the file_exists() functiion but in case you are working with a password-protected server, this function would fail as the user authentication has not taken place. However, there is a workaround to this and I am going to describe it below- Step 1 : The first thing you […]
Posted on November 23rd, 2015 by Abinash Grahacharya
PHP has many predefined functions. Whenever you face a problem and search for a solution there is 90% probablity that you can find a php predefined function to solve your problem. While most functions are supported by PHP 4 there are a few new ones have been introduced by PHP5. Often these functions look identical […]
Posted on November 23rd, 2015 by Danish Ahmed
XAMPP does not enable cURL library by default, you have to tweak around a bit to getit up and running. Here is how… But before that let me explain what cURL is for the benefit of the uninitiated (i was one of which, just a couple of months back!), cURL is a command line tool for […]
Posted on November 23rd, 2015 by Shweta Chottray
PHP doesn’t require variable initializations, which means we are writing insecure code that is easier to invoke one page from others own form or the browser address with fake variables and that cause a big security issue. When the “register_globals=on” register_globals will supply all the variables to the script. Any one can initialize the variables […]
Posted on November 23rd, 2015 by Asish Tripathy
Generally, a quote is used to create a string. A quote can be a single quote( ‘ ‘ ) or a double-quote ( ” ” ) but in PHP they should not be considered the same! The reason for this is that the double-quote is parsed by PHP while string created with single-quotes are not. For example: //In both case output is […]
Posted on November 23rd, 2015 by Amrit Pattanayak
We can use rand() function to generate a random integer. But sometimes we need to generate random alphanumeric value. For instance, in password recovery mechanism we are often required to auto generate random alphanumeric value to be used as temporary password. This class can be used for the same purpose. <?php /***************************************************** * Purpose : Generate alphanumeric random […]
Posted on November 23rd, 2015 by Shweta Chottray
Sometimes our server shows a different time than the time shown on our clock, the most probable reason is that our hosting server is in a different time-zone. We can easily set our server time to our time zone changing a setting in PHP called date.timezone. In order to set the new time in every file, we need not […]
Posted on November 23rd, 2015 by Chittaranjan Pattnaik
For a lot of web developers it is a big task to make the web site as light as possible so that it loads fast in the user’s browser resulting in good user experience. Further, if the site is graphic oriented, with a single page displaying multiple images it becomes far more challenging. To avoid these situations […]
Posted on November 23rd, 2015 by Premananda Das
PHP .inc file issues To keep the configuration parameters many of us create include files and keep it inside the document root. Major concern regarding include files is the exposure of the source code through the user’s browser. Includes files uses a .inc file extension. Apache has no idea about the include files.The DefaultType of Apache […]
Posted on November 23rd, 2015 by Amrit Pattanayak
PHP provides inbuilt functions to do the MySQL database operations and we can use the functions in traditional way. But the following is an example of extended class which can be used for the same purpose. /*************************************************** * Define the database parameters (Usually defined in configuration file) ****************************************************/ define(“DBHOST”, “DB_HOST”);//Database Host define(“DBUSER”, “DB_USER”);//Database User […]
Posted on November 23rd, 2015 by Chandana Das
While displaying the email id of users in your application you can show it as an image to prevent the address from being mined by spammers. The following code snippet shows how you can quickly create text as image <?php // Create a 160*20 image $im = imagecreate(160, 20); // background color $bg = imagecolorallocate($im, 255, 255, 255); //text […]
Posted on November 23rd, 2015 by Abinash Grahacharya
At times we do face problems modifying names of a table or a column after the application has been scaled. This is more problematic when working with large applications as I have learnt from experience. It generally requires a lot of rework with existing codes. So lately, in my PHP projects I have been using global_db_config […]
Posted on November 23rd, 2015 by Abinash Grahacharya
In many projects we need to generate the time difference between the current date and the date the record was created. For example, suppose you want to get the date difference of number of comments related to present date and time. What possibilities come to your mind ? First I thought of getting the date time from […]
Posted on November 23rd, 2015 by Subranil Dalal
When we create or read XML file in PHP we use DOM XML function. But PHP 5 provides a great function SimpleXMLElement(). This function is very simple to read or write any XML. This function is more simpler than DOM XML of PHP 4. SimpleXMLElement has lots of functions. Here I am discussing some basic […]
Posted on November 23rd, 2015 by Subranil Dalal
At times we need to check if a folder is empty or not before performing an operation on it. For this, I have written a function which returns TRUE if any file or folder is found inside the folder and FALSE if the folder is empty. /** * Checking a folder is empty or not. * @param string […]
Posted on November 23rd, 2015 by Subranil Dalal
In php unzipping a zip file is always different for separate OS. Though most php sites are running on Linux there are a few on Windows too. Here I have written a class to programmatically unzip a zip according to the OS Linux/Windows . My class is OS independent, it automatically detects the server’s OS and processes the unzipping […]
Posted on November 23rd, 2015 by Asish Tripathy
At times we need to add a page content to a email body. Also some time we need to call a api link to get the data. Here is a function which will help you to read the page content of a given link and return the data in an array. So that you can use […]
Posted on November 23rd, 2015 by Abinash Grahacharya
Demostrated below is a sample of how PHP PEAR library can be used to implement AutoComplete functionality of a text box. <?php require ‘HTML/QuickForm.php’; $teams = array(‘Amit’,’Satyan’,’Saswat’,’ Chinmoya’,’Sonali’,’Kiran’,’Ansuman’,’Hemendra’); $form = new HTML_QuickForm(); $element =& $form -> addElement(‘autocomplete’,’teams’,'<font style=”color:red;font-size:11px; font-family:verdana;”>Favorite Engg Team:</font>’); $element -> setOptions($teams); $form->display(); ?> Now, save the file in a virtual directory […]
Posted on November 23rd, 2015 by Abinash Grahacharya
In many PHP projects we need to display graphs and for that we download some free Flash graph examples and use them. In this tip I will describe how to create a simple line graph using PHP itself. We have to create a php page and call it graph.php or anything else you want. […]
Posted on November 23rd, 2015 by Asish Tripathy
Most of the time we pass unique values as parameters with the url to use the value in the target page. But passing the value directly causes security issue. For example we used to pass some id to view the detail of the selected item. But user can change the id on the address bar mannually and […]
Posted on November 23rd, 2015 by Abinash Grahacharya
In JavaScript replace function is basically used to replace some string in an another string. For instance, if your main string is var main_str =”i am working as a php developer,php is favorite language “; and you want to programmatically replace php to JAVA, you have to write the code as: main_str = main_str.replace(/php/i,’JAVA’); Here,as you can see we calling the replace function with […]
Posted on November 23rd, 2015 by Jyotiprakash Dhal
In recent past, we had a requirement in our project where our client wanted us to show Amazon products on the site so that users can view Amazon products and add their favourite products to their cart which they can buy later during checkout process from Amazon. It helps us to attract users and increase […]
Posted on November 23rd, 2015 by Subranil Dalal
In many of our project works, we need to get geophysical location of an end user, including more information on country, state, city, timezone, offset time, based on the user’s IP address. Here I am using http://ipinfodb.com/ API to get the IP info in xml format. I make an Ajax call to PHP page which gets the XML […]
Posted on November 23rd, 2015 by Deepak Biswal
In PHP array_count_values() is used for counting array value with case-sensitive matching. But what if somebody needs a function for counting array value with case-insensitive matching. <?php function arrCountValueCI($array) { $countArr = array(); foreach($array as $value) { foreach($countArr as $key2 => $value2) { if(strtolower($key2) == strtolower($value)) { $countArr[$key2]++; continue 2; } } $countArr[$value] = 1; […]
Posted on November 23rd, 2015 by Subranil Dalal
AJAX technology has gained considerable popularity in the world of web and especially Web 2.0. so much that it would be difiicult to find a web developer who hasn’t been exposed to the benefits of this technology. Sometimes in our project work we need to keep refreshing a page in a certain time interval. For instane, take a live online […]
Posted on November 23rd, 2015 by Satheeskumar A
Instead of designing and writing the data in a Excel file, it is much easier to have a template with all the designs embedded. We have to just read the template file and write our data in the particular cells. But if we are going to have, say, ‘n’ number of sheets, then the template file also should […]
Posted on November 23rd, 2015 by Satheeskumar A
It is difficult to a render a chart in a XLS file while generating it from PHP. But its possible to link the data from a different XLS sheet and to refer it to your sheet through which you can perform calculation or even alter the charts dynamically. To do so, please follow the […]
Posted on November 23rd, 2015 by Tanay Mukherjee
Breadcrumb is the trail you took to arrive at your current location. Text breadcrumbs are common on Web sites to help users navigate the site. For example, breadcrumbs such as Home > Menu > SubMenu indicate that the SubMenu page you are looking at was retrieved by first clicking Home, then Menu and then SubMenu. […]
Posted on November 23rd, 2015 by Subhranil Dalal
In PHP, normally we create PDF using FPDF class by plotting all data against the (x,y) co-ordinates or create the html layout and convert it to a pdf using HTML to pdf. But when we are filling up forms with a number of fields such as an insurance claim form it becomes difficult as we […]
Posted on November 23rd, 2015 by Runish Kumar
I just read about PHP Data Object(PDO) and found it really interesting and useful, so I decided to share this with everyone. Introduction to PDO: To explain it better let me take a hypothetical situation, suppose you are working on a project which is almost complete and then you come to know that the client has switched to PostgreSQL database instead […]
Posted on November 23rd, 2015 by Satheeskumar A
In my current project, I found myself facing a time exceeding issue,the program was taking nearly 13 minutes to generate a report which was very unusual because the page didn’ t have any complex queries or loop to iterate. As i am working in an accounting project, it seems to be a strange problem to us. Because […]
Posted on November 23rd, 2015 by Sambit Mishra
Many applications need graph implementation because its a good way of representing data. It is also very eye catching. So here,I am going to describe various ways of creating Graphs(simple to animated). There are many sites which provide garphs. But here I am going to discuss about 2 libraries i.e. libchart and Fusion Chart. Lib […]
Posted on November 23rd, 2015 by Vikram Mishra
Most of us uses the PHP’s opendir() function to open a directory and then loop through the directory for reading its content using readdir() function which requires a lot of repetitive code every time we search for a folder. Today, I came to know about PHP’s glob() function which is much smarter than opendir(). […]
Posted on November 23rd, 2015 by NIRANJAN SAHOO
The following function returns the sql query executed. $this->db->last_query(); This is specifically used for debuging purpose. Also one can see the sql query without the above just simply by making maistake in the column name or table name in the model files. For example – the actual table name is “products” .here one can make […]
Posted on November 23rd, 2015 by Sandeep Thadvai
When we retrieve the data from mysql and use json_encode to convert to JSON format. If it returns null then there are two points we should keep in mind i.e., 1) You may be retrieving data in non-utf8 encoding: so, after retrieving use Soln: (i) $store_name = utf8_encode(name_of_varaible); (ii) […]
Posted on November 23rd, 2015 by Manash Khamari
Most of the time when we work on data driven projects, which involves user submitting records related to specific set of data, often there is the need of charts, to show user some diagramtic representation of the data entered. When it comes to showing charts in the user browser, Fusion Charts is the best of […]
Posted on November 23rd, 2015 by Manash Khamari
Few days back I ran in to a requirement, where there was a need to frame a picture, of any size, uploaded by the user. First I thought this can be done via the gd library extension we have in php. But all try to make it work using GD, failed. As the framing process […]
Posted on November 23rd, 2015 by Swarup Sahu
Session in iframe is working fine in all browser except in Internet Explorer (Very Astonishing). The reason behind is that IE blocks the iframe cookie/session. To over come this, just add P3P Compact Policy header(the line of code given below). It will allow IE to handle third party cookie/session. Code: header(‘ P3P: CP=”CAO […]
Posted on November 23rd, 2015 by Sukant Shekhar
Challenge: I was given a scenario in which i need to represent a large number by few character it must be hard to break the code. For ex: A 8 digit number into 5-6 character. That too uniquely identified per number (i.e code corresponding to each number should not match the code corresponding to different […]
Posted on November 23rd, 2015 by Puja De
These are the steps to accomplish how to avoid duplicating multiple posts Step 1: Add the following function function post_strip($where) { global $myPosts, $wpdb; $where .= ” AND $wpdb->posts.ID not in($myPosts) return $where; } Step 2: Start the First Loop <?php global $myPosts; $myPosts = ”; ?> <div> <?php $my_query = new WP_Query(); $my_query->query(‘showposts=5’); […]
Posted on November 23rd, 2015 by Dinesh Sahoo
If we have read/seen it somewhere that ” File upload using Ajax”, then it is not through AJAX. File uploading is basically done through an iframe in this case. We have to use an iframe to upload the files. Honestly speaking implementing javascript code using an iframe is quiet difficult for a beginner. In that […]
Posted on November 23rd, 2015 by Abhishek Mohanty
Sorting arrays is easy using PHP, thanks to the sort(), ksort(), and related functions. You can sort a one-dimensional array by key, by value, in reverse order, etc. But these functions will not work on multidimensional arrays (not as you’d probably like, at least). So, many a times beginners end-up creating their own logic to […]
Posted on November 23rd, 2015 by Supriti Panda
While working on a community project, this is what I learned. In my site a custom flash player is used to play the videos. That player can be customized for each member. They can create their own player with the selected videos and publish it in their site. So they want to know how many […]
Posted on November 23rd, 2015 by Tapaswi Panda
While registering a new user to our application we generally check if the userId already exist by doing a select query. If the userId exists we should not allow to create another user with same ID. Below is a handy script which explains how we can avoid doing the select query and register a new […]
Posted on November 23rd, 2015 by MANISH AGARWAL
In Active Directory database users password are stored in ‘unicodePwd’ field which is normaly not accesible through code. you can not read this field value. You can only modify the value of this field password but there are some circumtances under which you have to do this. Below I have describe these circumatances: – Secure […]
Posted on November 23rd, 2015 by Annada Palit
PHP 5.4 has built in web server which helps in executing it without starting Apache. Steps to follow for testing this feature : ————————————————— 1. Add .PHP extension to the PATHEXT system environment variable 2. Extract the PHP folder and put it separately where you like 3. Open cmd and run cd […]
Posted on November 23rd, 2015 by Sandeep Agarwal
1. Avoid writing naive setters and getters: Save time and speed scripts by working with object properties directly, rather than writing naive setters and getters. EX: class test { public $name = ”; public function setName($name) { $this->name = $name; } public function getName() { return $this->name; } } //Notice that […]
Posted on November 23rd, 2015 by Vinod Mohan
The following function can be used to check if the time format given is in HH:MM format or not. It takes user input time a the parameter,checks for the format and returns TRUE for success and False for failure. /** * Validates Time in 24 hour format (e.g. 20:32). * * @param string $time Name of submitted […]
Posted on November 23rd, 2015 by Sandeep Agarwal
PHP security is very important, as insecure php code can trigger in intrusion to your server. Below are some of the common issues that we can take care of. 1. Issues with Permission: Problem: 777 as the file or directory permission will allow the nobody user to edit the file and execute it. Solution: Always […]
Posted on November 23rd, 2015 by ARJITA MITRA
In NetBeans it may happen with you that you are selecting a theme but its not showing any effect in your file. To select a theme you need to go – Tools => Options => Miscellaneous => Fonts & colors Here you can see a drop down named Profile . Now if your theme is […]
Posted on November 23rd, 2015 by Abinash Grahachrya
Solution The javascript event, “onselectstart “, can be used to handle this issue , To prevent elements within the div from being highlighted while dragging we can use the following statement. <div onselectstart=” return false”></div> //this function will perform as onselectstart forboth in IE and FF function disableSelection(target) { //For IE This code will work […]
Posted on November 23rd, 2015 by Abinash Grahacharya
If you want to load your website faster and have good ranking for your website in y-slow of similar tools please go through this tip. I have discovered a technique for adding javascript and CSS files at run time, it has been checked in various ways and I am also giving the sample code to […]
Posted on November 23rd, 2015 by Subranil Dalal
In my previous tip ‘How to get Skype status on the web application and make call or chat from web application’ I showed how to get skype status by getting a skype icon. But at times we need to get the skype status in text. Here I am giving an example of how to get […]
Posted on November 23rd, 2015 by Swarup Sahu
n one of my projects, I need to generate XML response for a request. The XML response is like below: <?xml version=”1.0″ encoding=”UTF-8″?> <result>result</result> <error>error number</error> <message>Message text</message> But when I tried to retrive the XML from another page by putting a request, I found an error: ‘parser error : Extra content at […]
Posted on November 23rd, 2015 by Bimal Biswal
At times I have come across “Access to restricted URI denied” code: “1012 even when making a legitimate AJAX call but from a different directory/site level. I know this is a security feature to restrict cross domain AJAX call. But firefox throws this error when calling a file in the same domain also (but not […]
Posted on November 23rd, 2015 by Smarjit Debata
It is really interesting to access webservices of yahoo using SQL like comands called YQL, Yahoo Query Language. YQL webservice has pre-defined tables for Flickr, MyBlogLog and some other webservices. Moreover, an user-defined Open Data Table can be created to access data sources of webservices other than Yahoo!. The output can be recieved in either […]
Posted on November 23rd, 2015 by Avishek Sharma
Suppose we have multiple independent objects, and we are given a task to clone those objects. We fetch source object ids in an array($test has the id in this example), and start cloning. Now suppose we get an exception at say object no 2 it is fine as we are catching it and logging it […]
Posted on November 23rd, 2015 by Swarup Sahu
In one of my projects, I was working on Google calendar, the tasks included creating an event, updating an existing event, deleting event etc. I did not face any problem while creating and deleting an event, but while trying to update an event it gave me an error ‘Bad request/Invalid data’. After a long try […]
Posted on November 23rd, 2015 by Vijay Goyal
SessionStorage is an alternative to session cookies, but more powerful. The data recorded in the storage are available in all web pages from the same site and to the same user during the session. However, the real advantage is that when using Session Storage it is possible to carry out multiple transactions in different windows […]