28
Dec

7 Most Useful WordPress Plugins For Your Site

Almost 75 million websites use WordPress for their content management service. Out of around 120 plugins, it offers almost everything your website needs to operate in their domain of work. But a wise choice among all of it is required in order to reduce page load time when almost 7 to 10 seconds of attention is all you have. This list of seven wordpress plugins when optimally used will work out to be the best for your website:

Read more

9
Jul

How to Import SQL File Within WAMP Environment Using Command Line

This is something I’ve done already so many times, but just because I don’t do it every month, I forget it all the time. So, I thought I would make a reminder note to myself and anyone else who has similar problem :

The easiest way for me to import an sql file into a database in WAMP environment using command line is using follwoing:

1. Run the cmd (DOS) and get into the mysql folder, which in my case works like this

[php toolbar=”false” classname=”one_line”] C:\>cd C:\wamp\bin\mysql\mysql5.0.51b\bin
[/php]

Read more

9
Jul

PHP: Increase PHP Memory Limit in htaccess, apache or in a php script

Most of us have come across this error: “Fatal error: Allowed memory size of xxxxxx bytes exhausted (tried to allocate yyy bytes) in ….” in the php error logs.

In php, running out of memory in usually a sign that your php script is not too well written or has a bug or two in it; However sometimes even the best of our php scripts still require more memory than usual especially if it is handling large amounts of data.

Luckily in php, increasing the memory limit is an easy task to do and can be done in a number of ways.

Read more

9
Jul

PHP: Calculate Time Difference Between your Users And Your Server

People access your site aren’t always in the same timezone as you are. Now perhaps you would like to determine what the time is for a user in a different country. Then here is a quick way to find this information out.

This example is very useful if you simply want to fetch your clients date and time or timezone; but also good to see what time of day (their time, not server time) your clients access your website.

Now before I should you the code, remember that PHP is server side code – ie. it runs on the server and as such doesn’t have access to the clients local time. Javascript however is client side code which means it can see the localtime but the servers time. So a combination of the two will allow us to calculate the difference.

The way the below example works, is that the client will click a submit button which sets the value of the hidden input field to their local time stamp and that gets submitted to the same php script. Then the php script checks if that value has been sent and if it has, then it gets the local time (of the server) and takes the clients times and shows a message depicting the difference.

Read more

9
Jul

PHP: Complete List Of File Mime-Types

Below is a list of mime-types I come across most often. Suggest others that should be a part of the list by leaving a comment below. You can also view my article on finding the mime-type of a file by check out my article on PHP Function To Get File Mime Type.

Text

PHP – text/html
HTML – text/html
HTM – text/html
CSS – text/css

Read more

9
Jul

.htaccess: Set custom 404 error page

Apache allows you to customize the server at the directory level, using .htaccess files. Below how to use them to serve custom 404 error (page not found), and other common error pages, to your users.

Alternately, You can place the 404 error template anywhere you want in a folder. For example you could place all error messages in a folder called “errormsg” refererring the 404 error to the url of the page.

[php toolbar=”false” classname=”one_line”] ErrorDocument 404 /errormsg/404.php [/php]

Read more

9
Jul

How To Update Facebook Open Graph Cache

Have you ever tried to post a link to your content on Facebook only to realize that an image is missing or the description isn’t there?

Naturally, you go back to your edit your article and add the missing content. Then you head back to Facebook and try to post the link. What, Facebook still isn’t showing the new content? Why? It is caching the Open Graph data!

How can you get Facebook to update cache data on a link?

  1. Go to the Facebook Open Graph debugger (https://developers.facebook.com/tools/debug)
  2. Enter the URL of your link and click Debug
    debugger-facebook-developers
  3. Verify that the updated content is being fetched by Facebook in the “Object Properties” area
  4. If the new content is there, return to Facebook to add your link

In my experience this process has updated the Open Graph cache on Facebook every time.

Disclaimer: this is not a documented process by Facebook.

What is Open Graph?

Learn more at http://opengraphprotocol.org/




9
Jul

.htaccess : Redirect non www to www

It occurred to me that just maybe you don’t want to display your site with the www subdomain prefix. In that case you could deploy the following code in your .htaccess file to redirect www to non-www. By doing so, users will access your site at http://domain.com not http://www.domain.com.

.htaccess

If your website is hosted on an apache server, a redirect from www to non-www is a simple implementation. Add the following to your .htaccess file

[php toolbar=”true” classname=”one_line”] RewriteEngine On
RewriteCond %{HTTP_HOST} !^domain\.com
RewriteRule (.*) http://www.domain.com/$1 [R=301,L] [/php]

Add the above code to you .htaccess file and replace domain.com with your domain name.

9
Jul

Using XML: A PHP Developer’s get data

This series of articles will focus on XML, its applications in modern day web development and how PHP fits into this niche. In this article, we will focus specifically on the tools provided to us by PHP which enable us to manipulate XML data sources.

What is XML and Why Use it?

XML (eXtensible Markup Language) is a W3C standard designed to allow the easy exchange, storage and use of data between web applications and services.

Read more

9
Jul

Css: Media Queries for Standard Devices

First add meta tag in Head of Html :

Html Code:

[php toolbar=”false” classname=”one_line”] <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
[/php]

Read more