Changing the URL of a WordPress website

Recently a client bought a new domain name and wanted the existing WordPress site to change its domain to use the new one instead of the current one. After much research, I created and followed a plan for changing the URL of a WordPress website.

Here are the steps I followed (one.com is the existing domain and two.com is the new domain):

  • Make sure the new domain is parked or pointing to default servers.
  • There are a few methods to change the WordPress Site URL and Home settings, but I chose changing it via PhpMyAdmin.
  • In the hosting, set the primary domain for the hosting to be two.com.
  • Set up a 301 permanent redirect for one.com to point to two.com.
  • Log in to the dashboard. Go to Permalinks and just Save/Update.
  • The SSL certificate adjusted automatically.

A few plugins needed settings adjusted, but that was it!

Implementing Form Script that Works with php 7

I recently upgraded hosting to php 7.0 since some of my WordPress sites were recommending the upgrade. The WordPress sites were fine, but one of my two last remaining HTML sites was using the Huggins Email Form php script, which isn’t compatible with php 7.0, and so the form started getting server 500 errors.

I looked up a resource I had used for a form for another HTML site, which was the ReusableContact Form Using Bootstrap And PHP.

Just download the zip file, and extract to the root directory for the site.

To test it, see the steps listed on the page where you got the zip file from.

To completely integrate it, I followed these steps:

  • Edit src/formhandler.php to change the email Subject and From.
  • Add any form field validations to handler.php.
  • If you’re using recaptcha, put the site key in the form (you’ll see the example in the formpage.html file), and put the secret key in handler.php.
  • Also, put the destination email address in handler.php.
  • Make sure you refer to the example formpage.html for including the link rels and script statements in the header and the recaptcha script in the body.

The next challenge was implementing a second form for that site. Fortunately the forms were on separate pages, so I didn’t need to use different form ids. I was able to use a generic Subject for both form emails, so no changes needed there. The second form worked fine. I suppose if I needed separate Subjects, separate recipients and separate field validation for each of the forms, then I’d need to figure out how to modify handler.php and formhandler.php. At some point, though, both of the remaining HTML sites will be converted to WordPress and I won’t need form scripts anymore!

 

Unknown Collation Error Migrating Newer MySQL DB to Older MySQL DB

Today I will explain how I was able to fix the Unknown collation error when importing a MySQL database.

I was moving a completed WordPress site this weekend from my hosting account to a client’s hosting account and was surprised to receive an error upon importing the database into the new empty database.

The error was:

Unknown collation: ‘utf8mb4_unicode_520_ci’

Upon Googling it, I discovered that this is a typical error when importing a database from a newer version of MySQL to an older version of MySQL.

The solution was pretty simple. Export the database in a format that is compatible to both, which turned out to be MYSQL40.  I also chose that format when importing the database. Worked fine and I was back on track again.

Update: 2/25/2019

I just did another export/import to move a development site to ‘live’.

This time I got this error: ERROR 1115 (42000): Unknown character set: ‘utf8mb4’

One of the solutions I found while googling was to edit the exported SQL file with a text editor and replace all ‘utf8mb4’ with ‘utf8’.

So I tried that, and then got the same error as before: Unknown Collation: ‘Utf8_unicode_520_ci’

A different solution that the one I used originally was to edit the exported SQL file and replace ‘utf8_unicode_520_ci‘ with ‘utf8_unicode_ci‘.

So I imported the modified SQL file and it worked!

 

Changing WordPress Max File Upload Size

I was Googling around, looking for an easier way to change the max file upload size when uploading files to the WordPress Media library and ran across this post on Brian’s Tips and Tricks for Web Developers website.

You can easily change PHP values by going to the Select PHP Options page under Select PHP version in the Software section of cPanel. When you’re on the Select PHP version page, choose Switch to PHP Options at the top right.

Click on the value, make a selection, Apply and Save.

Troubleshooting Reasons for an Unusually Large WordPress Database

My client informed me that when she viewed her website, it was displaying the “Error Establishing Database Connection” message.

When I went to wp-admin, it was displaying another similar message about the database. I logged into the Control Panel and was able to view the database in PHPMYADMIN. I checked to make sure the database name, username, and password matched. Called GoDaddy and found out that the database was over the limit allowed by the hosting plan and so the database user was disabled. We had one week to resolve the issue either by reducing the size of the large WordPress database or moving to a hosting plan that had unlimited database space.

I  browsed the database using PHPMyAdmin, and eventually found that there were over 1 million records in wp_posts! Next, I asked the client to move to a higher level hosting plan and got the site back online. There were only about 1,000 actual posts when viewing Posts from the Dashboard. I continued to browse wp_posts and finally something caught my eye. There were lots of posts of Post-type Http, and a field contained ‘core_control_http_log_item’. I Googled the character string and came up with one match! Googled translated the page from French and I found the answer. It was the Core Control plugin, which had been active for several months and had been logging activity in the database. I had been using it to debug Paypal connection problems and had not disabled it.

Next, I had to remove all posts of post-type http. I used the query:

DELETE a,b,c FROM wp_posts a LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id) LEFT JOIN wp_postmeta c ON (a.ID = c.post_id) WHERE a.post_type = ‘http’.

I hope this may help someone else who discovers that they have a large WordPress database that shouldn’t be so excessive in size and need to find the reason why.

How to Troubleshoot Contact Form 7 Configuration Error

Process of Elimination for Contact Form 7 Configuration Error

I use the Contact Form 7 plugin on almost all of the WordPress sites I create. Recently, I was creating a very long form, saving frequently, and then noticed there was a configuration error: “Multiple form controls are in a single label element. ”

I looked through the code and nothing jumped out at me that could have been wrong.

So I thought, how am I going to find the error? There were almost 50 input fields!

Answer: Process of elimination

I opened up Notepad, copied the entire form, and pasted it into Notepad.

Next I went back to the form, and deleted all but the top several fields. Saved it. No error.

This told me that the error was somewhere in the remaining part of the form.

I copied the next few fields from Notepad and pasted it at the bottom of the form.

Saved again. The error showed up! So now I knew the error was in the fields I had just pasted.

So, I used this process to isolate the part of the form with the error. It saved a lot of time that I would have spent going over the code repeatedly, looking for some problem.

I hope this tip will save you time. It can be applied in situations other than just html forms, too.

Turned out the error was a misplacement of the closing ‘label’ tag.

Troubleshooting Outlook Express Errors 0x800CCC0D and 0x008CCC0E

Every once in a while, Outlook has an error such as “Can’t find host – cannot Locate Server” or “Failed to Connect – Cannot Connect to Server”, error codes 0x800CCC0D and 0x008CCC0E. I found the notes below and thought posting it would be a great way to store the info in case I need it in the future.

I found this very helpful link for troubleshooting those errors and other Outlook errors such as Client Response Invalid.

Some other tips:

  • If outgoing port 25 is being blocked, try setting the port to 587.
  • To clear cache and flush DNS, go to DOS command prompt and enter ‘ipconfig/flushdns’
  • Try Control Panel > Network Connections > Local Area Connections. Right-click and choose Repair

Starting Outlook in SafeMode – Tools > Options > Other > Advanced – Add-in manager, clear checkboxes; restart Outlook

 

By |April 30th, 2017|DNS, email, outlook, WordPress|Comments Off on Troubleshooting Outlook Express Errors 0x800CCC0D and 0x008CCC0E

Not Receiving Emails from WordPress Contact Form

This happens frequently – you install Contact Form 7 or Fast Secure Contact Form plugin on your WordPress site and you’re not receiving emails sent through it — they just never arrive in the Inbox. Sometimes this can be due to the settings in the form, such as From: [your-name] <[your-email]>. Contact Form 7 has some good documentation on troubleshooting email delivery here.

Sometimes it can be due to an incorrect setting on the host. The cPanel MX Entry is set to Local Mail Exchanger by default but should be set to Remote Mail Exchanger. This means that if a form in your website uses email@yourdomain.com and it’s the same as your website, the web server will attempt to handle the email itself (because it also hosts your site). To solve the problem, change the setting in cPanel to Remote Mail Exchanger which will tell the server to use the MX records to route the email. This problem can occur with any host that uses cPanel including GoDaddy, HostGator, etc. In GoDaddy, this setting can be found under Hosting > Manage > Email > MX Entry. You may also need to add an MX record with priority 10 and remove, if any, an MX record with priority 0.

This happened again recently with a site hosted at GoDaddy but the email was hosted by Google GSuite. The five Google MX records were in place but no email was being received through the forms on the website. Setting under Control Panel is found under EMail then MX Entry and check off Remote Mail Exchanger instead of Local Mail Exchanger.

Allowed Memory Size Exhausted

I started getting the following errors on the frontend of a WordPress site:

Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 12288 bytes) in /home/aginginoudoun/public_html/wp-admin/includes/theme.php on line 523
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 3072 bytes) in /home/aginginoudoun/public_html/wp-content/plugins/sabai/lib/Sabai/Addon/System/Model/Base/AddonGateway.php on line 81

A Google search indicated that the software was reaching a PHP memory limit, so I ran a phpinfo.php and saw that both local and master memory was 64M. Further reading advised creating a .user.ini file, put the following line in it: memory_limit = 256M, and place the file in the public_html folder. So I did this, and ran phpinfo again and saw that local memory was now 256M and master was still 64M. Supposedly the local overrides the master value.

Tested the website again, and no more fatal errors!

P.S. Don’t forget to remove your phpinfo.php file from the site.

Moving WordPress Development Site to ‘Live’ Site

I just recently moved a WordPress site I’ve been developing using a different domain name to its final destination as a ‘live’ site. I’ve done this several times before but this time I wanted to document the process for future reference.

The development site is sdspreview.com. The current site is named 3dogfarm.com and is an HTML site. The two sites are both on GoDaddy but under different accounts.

Here is the process I used:

On Development Site –

  • Bring up to date all plugins, etc.
  • Install the Go Live Update urls plugin
  • Go to Settings > general and change wordpress address and site address to 3dogfarm.com

Log in to hosting for sdspreview.com
Go to root directory for the site, select all files and Archive (Compress) into zip file.

Download zip file to my PC

Go to PHPMYADMIN and export database to PC.

Go to hosting where WordPress site will be. Install WordPress in root folder.

Locate WordPress database that was just created. Import the database that was exported to PC.

Upload zip file to root folder.

Extract zipped file to root folder.

Go to Databases and find out the database name, username, password, and MySQL host name.

Go to root and edit wp-config.php – update the database name, username, password, and MySQL host name.

Log into the site – reset password if you’ve forgotten it.

Run the Go Live Update URLs plugin to change any lingering occurrences of the old url. Sometimes this plugin recommends against updating the tables for certain plugins. When that happens, I usually do skip those tables and then do a search and replace in PHPMyAdmin using the queries in this article: https://www.hostinger.com/tutorials/wordpress/how-to-change-wordpress-urls-in-mysql-database-using-phpmyadmin#gref

Review any widgets to ensure no old urls are there.

Enter Google Analytics code and set search engines to allow indexing.

Sometimes I also have to go to Permalinks and just click Update to fix any old URLs.

Done!