Apache · Backend · WordPress

Mac Locahost uploads broken after Mac OS Upgrade

Before the recent MAC OS upgrade, wordpress plugin updates were working fine on my local development environment.

Then I started getting messages like “upload failed server error” when attempting to update wordpress plugins from my local hosted wordpress sites.

At first, I made sure the permissions were correct and that the files and directories had the proper owner. But this is did not fix the issue.

This is when I realized that something must have changed in the apache set up.

For now, I am still using PHP 5 on these local servers (soon switching to 7)

The apache configuration file had been silently altered by the Mac OS update!

Apple makes a backup of the existing apache configuration file before replacing it.

Performing a command line diff, I was able to see what had changed.

LoadModule php5_module libexec/apache2/libphp5.so had been commented out!

Uncommented the load module command for php5_module (or whatever PHP version you are using) finally restored the upload functionality of my local server.

I hope this helps someone find the answer to this issue a little faster!

MySQL · WordPress

Why New Domain Keeps Forwarding to Old Domain [Solution]

After changing a domain name and updating the DNS records you might find yourself baffled by the fact that the site continues to redirect to the old domain. You may be frustrated as you have seemingly tried everything.

Likely, you are dealing with a WordPress site. With a WordPress website, references to the domain name are hard coded into the database.

Migrating WordPress site to new Domain Name

After changing a domain name for a WordPress site, the database will need to be updated to reflect the change. Failing to change the references to the old domain name in the database means the site is still attempting to point at the old domain name.

To fix this issue, perform the MySQL queries shown below. In case it is not obvious, replace ‘old-site’ with the name of your previous domain name, and replace ‘new-site’ with your current domain name.

CAUTION: Remember to first make a backup of your current database.

MySql queries for migrating site to new domain

The MySql queries for migrating site to new domain are as follows:

Solution to Error · WordPress

[SOLVED] ERROR mysqli_real_connect(): (HY000/2002): No such file or directory

If you are getting a wordpress error that starts with “mysqli_real_connect(): (HY000/2002):” and includes “No such file or directory” and ends with “wp-includes/wp-db.php on line 1490”, then here is what resolved the issue for me.

In the wp-config.php file, include (or change) this line from

define(‘DB_HOST’, ‘localhost’);

to

define(‘DB_HOST’, ‘127.0.0.1’);

I put it near the top. Hopefully this will help someone.

leave a comment : )

AJAX · Backend · Drupal · Drupal 6 & Drupal 7 · Frontend · MAMP · PHP · Web Design · WordPress

Get The Calling Function

Knowing which PHP function call the code we are working on can give us the clues we need for de-bugging a script.
Getting the calling function is easy in PHP, thanks to the debug_backtrace() function.

Just put the following code wherever in your script you need to know what function is calling the part you are working on.

This will output something like this:

The function that just called this code is DrawWidget.

Where DrawWidget is the name of the function.

I hope this comes in handy for someone. Thanks for visiting!

Backend · MAMP · MySQL · WordPress

Import WordPress Database from Staging Server to Local Development Server

You may be working with a WordPress project and wish to use SVN to have a development instance, a staging instance, a local development instance and of course a production instance of the web site. This could prove to be problematic in keeping track of your data base instances. WordPress stores the root URL (http://website.com) at several places in their database. This can cause a problem when you try to import a copy of one of the live databases to your local development environment. When ever you click on a link it will send you to the live instance instead of remaining on your local environment. A way around this, for local development environment purposes, would be as follows:

  1. prior to importing the .sql file, open it in your favorite code editor. I like to use BB Edit.
  2. Perform a search and replace on the .sql file for the root url.
  3. ie:  search for “http://www.livestagingserver.com” and replace with “http://mylocaldev.me”
  4. Save the file and import it into your local WordPress data base.

Now whenever you click on your posts in your local development environment the links will stay within your local development environment.
This way, you can keep a local copy of your database so you have a faster and more local way of working. This also serves to keep the live instance of the database from getting contaminated with the residual artifacts of development work.