wordpress update url database

Did you ever wished to change the URL for your wordpress site, or you have copied all files and database of a wordpress site to another site, and you wanted to change the URLs for the new one?

Below are the steps to be followed, to update the url settings of a wordpress site.

Step 1: Run the below queries in the database, to replace all the old URLs with new URLs:

Step 2 (Optional): Edit wp-config.php file to add the below lines to it, defining the new URL:



overlay div css example

The below example implements a div overlay on another div, by calculating the position, width and height of the first div, with jquery.

Here is a Demo.


jsonp ajax call jquery

Normally jquery ajax does not permit making cross domain requests.
So if we are on site A, we cannot make an ajax call to a page on site B, to get a json response.

This limitation is solved by using jsonp call of jquery ajax, specifying a callback function at both the sides.

Below is an example of making a jsonp call using jquery ajax.

The server side code must send ajax json response as a callback function, like:

Then the caller ajax code should implement the callback function:

Then loop over the json response, in the callback function:

Reference: Here


drupal display errors

In Drupal, normally we don’t see errors in the front end. But there might be few errors hiding here and there, which we would like to check during development phase.

For this purpose, it is easy to turn on error reporting with the below code. Place it in sites/default/settings.php:

Courtesy: Reference

Note: As a security measure, it is recommended to give the permissions of 0444 for the settings.php file. So if you change anything in the file, don’t forget to revert back its permissions to 0444.


slim framework

There are more than 10 frameworks for php, and each one has its own pros and cons. But one framework attracted me most. It is ‘Slim Framework‘.

It follows front controller design pattern, and since it is a micro framework, it is extremely light.

Developing apps using this framework is pretty simple. This framework can be used to implement REST based or backend service calls with ease. Just define a route and prepare the logic for it. The route can handle GET/POST/PUT/DELETE calls.

Here is an example of a REST based service in Slim:

When the end user hits the route /’users’, the corresponding function ‘getUsers’ is called, and the output is returned, which can be json, xml or plain text.

Now it is easy to call the above route with AJAX as follows:

Here is a reference for Hello World example.


php parse chrome bookmarks

If you are using a Windows system and if you know the location where Google Chrome stores the bookmarks, you can setup a php script to parse the bookmarks and display them in a tabular format.

Generally Google Chrome stores the bookmarks in a file named ‘Bookmarks’ (without any extension). The file contains the bookmarks data in json format.

On Windows 7 or Windows Vista, this file will be present at a location like:
C:\Users\{Username}\AppData\Local\Google\Chrome\User Data\Default

And on Windows XP, the path will be something like:
C:\Documents and Settings\{Username}\Local Settings\Application Data\Google\Chrome\User Data\Default

Once you came to know the absolute path to this file, note it down.
Now lets setup a php script that parses the bookmarks and displays them in a tabular format, in the descending order of the date they were added.

Note: Here I am using the bookmarks path as: C:\Users\admin\AppData\Local\Google\Chrome\User Data\Default\Bookmarks. It can vary based on your Windows OS version and username.


Online Web Tutorials