Wednesday, February 28, 2018

Fix 11 Common WordPress Errors Without Paying a Penny In 2018!

Fix 11 Common WordPress Errors Without Paying a Penny In 2018!

Link to My Blogger Tricks

Fix 11 Common WordPress Errors Without Paying a Penny In 2018!

Posted: 28 Feb 2018 07:01 AM PST

Wordpress errors could become a headache or a nightmare for a webmaster who may not be well versed with handling PHP errors or MySQL database errors. Thankfully WordPress community has matured so much since 2003 that today there is an answer for almost every problem faced by a WordPress user.

Fix Common WordPress Errors Without Paying a Penny

WordPress is used by more than 29.9% of the top 10 million websites as of February 2018. It is the most popular content management system with a market share of 60.2% while Google blogger has a market share of just 2% (We play a part in that share too!).

Our site (MBT) is hosted on blogger and we have not yet migrated to Wordpress for several reasons. Security, WP errors and hosting expenses are amongst the biggest reasons why we have not yet moved.

However we have four other sites which are hosted on WordPress and we enjoy using WP a lot. In this tutorial I will share 11 Common WordPress errors that we often face and their easy solutions as applicable in 2018.

After following this tutorial thoroughly, you will surely acquire enough skills to troubleshoot your WordPress blog without paying a penny to a developer. You can surely buy me a coffee with your savings if you wish to! ;)

1. Common WordPress Database Errors

Your entire wordpress posts, comments and pages data is stored inside MySQL database, which is an open source relational database management system.  Wordpress updates, adds, removes or deletes data from these databases by performing structured query language commands using PHP.

Every Web host provides a friendly user interface called phpMyAdmin using which you can easily solve the following database errors:

Cannot Create/Write to File

This error occurs when:

  • MySQL cannot create a temporary file

You can easily fix this problem by changing the tmpdlr variable to point to a writable directory. Follow these steps:

  1. Log into your CPanel and head to phpMyAdmin
  2. In the search box find the my.cnf file. On *nix systems this is usually in /etc/. Open it in a simple text editor and find the [mysqld] section.
  3. Under this section, find the tmpdir line. If this line is commented (has a # at the start), delete the # and edit the line so that it reads: tmpdir = /writable/dir where /writable/dir is a directory to which you can write. Change it to  /tmp
  4. Save the file.
  5. Shutdown MySQL by typing mysqlshutdown -u -p shutdown.
  6. Start MySQL by going to the MySQL directory and typing ./bin/safe_mysqld
  • The file permissions are incorrect

Every file has certain read/write/execute permissions grouped as:

  • Read 4 - Allowed to read files
  • Write 2 - Allowed to write/modify files
  • eXecute1 - Read/write/delete/modify/directory

You can easily edit the file permissions on your wp-content directory using an FTP client. I highly recommend you read the following tutorial by Wordpress to understand this problem in detail.

Unknown Column

There are two possible reasons why you are seeing this error. Either you are using incorrect quotation marks for the identifier quote character while running a database query or Wordpress Core update is not installed properly.

For the first reason I reason you go through the MySQL documentation to see what went wrong on your side.

For the second reason I recommend manually upgrading WordPress again by using a FTP client. Follow these steps:

  1. Get the latest WordPress zip  and extract the files.
  2. Deactivate all your WP plugins.
  3. Delete the old wp-includes and wp-admin directories on your web host using FileZilla
  4. Upload the new wp-includes and wp-admin directories to your web host, in place of the previously deleted directories.
  5. You must NOT delete your existing wp-content folder.
  6. Upload all files from the new wp-content folder to your existing wp-content folder, replacing existing files. Leave other files untouched.
  7. Upload all files from the root directory of the latest wordpress folder to your existing wordpress root directory.

That's it! If you have successfully replaced all files correctly then your site will be up in no time. If you get into a problem, do not panic and head straight to Google as there are tons of guides on stackoverflow and WP community forum.

These methods really empowers you to understand the core structure of WordPress and solve almost any error encountered in future. Master this skill and you can easily troubleshoot all WP errors!

2. Fix WordPress Error "Connection Timed Out"

When you put more load on your website than your server can actually cover, you are inviting this error. Since shared hosting have limited bandwidth and some webhosts like siteground provide only a limit of 25,000 pageviews a month, its common you may face this error during high traffic spikes or too much media being browsed. Such wordpress errors will be more commonly seen in 2018 as web hosting costs continue rising.

Following are few things you can try to resolve this error:

  • Deactivate all your WP Plugins. Reactivate them one-by-one to see which plugin is causing the problem. If deactivating all plugins did not resolve the problem then this error is not caused by a plugin.
  • Switch to a default WordPress Theme.  Switch to any default Twenty Sixteen WP theme to see if it is a theme problem.
  • Ask web host to increase maximum execution time in your php.ini file
  • Ask your webhost to increase memory limit .The memory limit in wp-config.php file is increased by your web hosting company.

These three things will hopefully resolve this error easily.

3. Fix Error WordPress "Establishing Database Connection"

You see this error when your server can not connect to your database. There are several reasons which could cause this. In my case following are the main culprits:

Incorrect wp-config.php Information

Using FilezillaoOpen up wp-config.php file and double check if the following details are correctly inserted:

  • Database name
  • Database password
  • Database host
  • Database username

All these credential details must match with those set  by you.

Compromised Website

I saw this error twice in 2017 when someone had compromised my site through a PHP contact form and got full control of the index.html page. In other words, you could see a database connection error when your site is h***ked.

You must immediately contact your webhost and inform them to restore your backup.

I highly recommend not to provide the "Upload" option in any of your website forms to allow readers to send you attachments. H***kers see it as an opportunity to attach malicious code that badly effects your data hierarchy and replaces your index.html page with index.php page of their own. This way they frighten you with a message on your homepage: "Your website is h***ked by XYZ!"

4. Fix 403 Forbidden Error in WordPress

If the error reads on your screen as:

Forbidden

You don't have permission to access '/' on this server.

Server unable to read htaccess file, denying access to be safe.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

403 Forbidden error is shown mostly when your server does not give permissions to access a specific page. This error is often caused by poorly coded third party security plugins, or server configuration.

To fix this error simply open Filezilla and locate .htaccess and delete it. Now check your site, if its resolved than your .htaccess file was corrupted.

You can then move ahead to generate a fresh .htaccess file. Simply log into WordPress and going to Settings » Permalinks page. Do not change anything and simply click the "Save Changes" button at the bottom of the page and you are done! A new .htaccess file will be automatically created in your root directory.

If in case you are looking for more details related to 403 error and want comprehensive tutorial on how to fix 403 error then head to this in-depth guide by 000webhost which covers A-Z details of WordPress 403 Forbidden Error and how to troubleshoot it.

I am sure the above methods will help you in easily fixing this error in future. Doing it for the first time will take some time and technical know-how but once you understand the basic steps, it would become a piece of cake the next time you encounter a 403 error.

5. Browser not showing the changes made on WordPress File Editor

Most often when you edit your CSS files or other related files in WordPress file editor, you fail to see the site reflecting the changes made.

This happens because the browser loads a cache of your last changes in order to speed up the load time the next time a user visits your pages. Even if you disable the WP Super Cache plugin or similar, the problem still remains there.  

To fix this problem, first try deleting your browser cache or close the tab and reopen the link.

If nothing worked, then hit Ctrl + U and find style.css link inside the source code of your site. Open it and then hit the refresh key (F5) 2-3 times. Now go back and reload the site to see the changes in action.

6. Custom Post Type 404 Errors

To troubleshoot 404 errors or custom post types follow these steps:

  1. Double check the names of Custom Post Types and static pages to see none have the same name. If they do, rename the single page, including the permalink.
  2. Next navigate to Settings > Permalinks. Select the option for default permalinks. Hit Save button. Then reselect your preferred permalink structure. This will update the rewrite rules and would solve the problem easily.

7. How to fix Pretty Permalinks 404

Most WordPress multisite users often experience 404 errors with pretty permalinks while uploading images. This happens because mod_rewrite is not be enabled in Apache by default.

To fix this error simply log into WP and reset your permalinks through Settings > Permalinks. Click the save button and you are done!

If this does not solve the problem then you can replace the contents of your .htaccess file with the following code either using Yoast plugin or Filezilla

# BEGIN WordPress  <IfModule mod_rewrite.c>  RewriteEngine On  RewriteBase /  RewriteRule ^index\.php$ - [L]  RewriteCond %{REQUEST_FILENAME} !-f  RewriteCond %{REQUEST_FILENAME} !-d  RewriteRule . /index.php [L]  </IfModule>  # END WordPress

8. Fix Internal Server Error

There are several ways that cause this error and we will discuss the major solutions to fixing this problem:

  • The most common reason is a corrupted .htaccess file. Simply log into FileZilla and copy your .htaccess file and save it on your local computer drive. Delete the one in your root directory. If the problem is fixed then regenerate a new .htaccess file by going to Settings > Permalinks > Click save button. This will generate a new .htaccess file.
  • Another reason could be a 3rd party plugin causing all the trouble. Deactivate all your plugins and see if your site loads properly. If it did load fine then try searching the plugin that was causing the problem by activating your plugins one-by-one until you see that error again. The last plugin you enabled is the culprit that you need to delete.
  • Switch the Theme to the classic WordPress Twenty Sixteen Theme to eliminate any Theme-related problems.
  • Another reason could be a memory limit. Contact your webhost and ask them to Increase the PHP Memory limit
  • The last and final method is to re-upload the wp-admin and wp-includes folders manually.

All these methods if applied correctly will surely bring your site back in order.

9. Fix the WordPress White Screen Of D***th

If you see nothing on your site's homepage but a blank page then know that its the WP white screen of d***th. It is caused either by a poorly coded WP plugin, theme or a corrupted .htaccess file. Apply all the methods that we discussed in point 8 i.e. "Fixing Internal server error".

10. How to fix syntax error in WordPress

Syntax error occurs most often when you incorrectly edit files such as functions.php file or any other file with .php extension using the WP file editor. You then come across an error on screen that either reads as "Parse error", "use of an undefined constant" or similar and shows you the line number where this error is occurring.

syntax errors in wordpress

A syntax error occurs when you make a mistake in writing the correct PHP structure code. It could be a missing terminator (;), or  comma, closing tag or a missing bracket.

If Parse Error error occurs then it means that you have forgotten to include a character. The most common are:

  • Unexpected '=' : you have not included the $ when referencing a variable
  • Unexpected ')' : you have not included the opening bracket (
  • Unexpected '(' : you have not included the closing bracket )
  • Unepxpected T_STRING: you have not included a quotation mark or a semi-colon at the end of the previous line
  • Unexpected T_ELSE: you have an else statement with no opening if statement

"Use of an Undefined constant" error also occurs when you have forgotten to include a character. It could be one of the following:

  • Missing a $ when referencing a variable
  • Missing quotation marks around array keys

The only way easy way to fix these errors is to open that specific PHP file in a FTP client such as FileZilla and make the necessary syntax edits and re-upload the file. That simple!

11. Fix Wordpress error "Maintenance Mode Following Upgrade"

Wordpress error Unavailable for schedule maintenance

Wordpress installs a .maintenance file when you run a WordPress update. During that time when WordPress is upgrading, your visitors will see this message for a short span of time "Briefly unavailable for scheduled maintenance. Please check back in a minute."

The maintenance file is a temporary file and is deleted as soon as the upgrade process completes but sometimes this file may not have been removed properly due to several reasons.

To fix this error simply connect to your site using FileZilla and inside the root directory folders, find and delete the .maintenance file.

That's it!

Conclusion

All these easy fixes really made my life at ease when I was new to WordPress. Not knowing these simple tweaks equals banging your head against the wall when you come across such frightening white screen errors. Educating yourself will not only reduce your development expenses this year (2018) but will also strengthen your technical skills and make you a well versed webmaster.

I hope this easy guide may help you in troubleshooting day to day errors faced in WordPress. I would love to answer any queries you might have. Please leave your queries in the comment box below.

Friday, February 23, 2018

How to Optimize and Use PDFs as Online Content?

How to Optimize and Use PDFs as Online Content?

Link to My Blogger Tricks

How to Optimize and Use PDFs as Online Content?

Posted: 23 Feb 2018 04:54 AM PST

As you probably know, PDFs are a very popular document format – mostly due to the fact that they can be viewed on any platform while preserving the document layout and formatting. Because of this universal compatibility they are often used for distributing or printing documents.

optimize PDF documents as online content

The one area where PDFs have traditionally not been very popular is as online content on websites. Although most web browsers can view PDF documents, the misconception that search engines could not index PDF files meant that many people avoided them for quite some time.

That myth has been completely debunked now, and Google confirmed that they have been indexing and ranking PDF documents since 2001. Still, it is important to understand that PDFs are a very unique type of content and if you do decide to use them online you will need to optimize them in several ways. This is a friendly A-Z guide on PDF SEO and best practices.

Make Sure the File Size is Low

One of the main issues with publishing PDF documents as online content is that their file size can be very large – which is especially true for long documents that have lots of images. That is far from ideal for online content, as it means that it will take longer to be displayed, which in turn could result in readers clicking away rather than waiting for it to load.

Additionally search engines regard page speed as an important metric when ranking webpages, and a large PDF file that loads slowly is likely to suffer on that front too.

Although there are no hard and fast rules, you should try to keep the file size of any PDFs you intend to use as online content as low as you can. That can be done through several means:

  • Avoid creating PDFs that are too long

    Thousand page PDF documents rarely make for good online content, and you're better off sticking to much lower page counts. Not only will shorter PDFs have a lower file size, but they'll also retain more readers.

    If you do have a PDF document that is too long, you may want to consider breaking it up into several shorter PDF documents. Alternatively you could extract the important parts and publish them individually.

  • Only use images when necessary

    Don't go overboard inserting images in PDF documents as each image can contribute significantly to its file size. Initially you should only insert images that are essential to the content, and later add others if the file size permits.

    The quality of the images that you add (for JPG especially) can make a large difference to the file size of your PDF documents.

  • Compress the PDF files

    When you export PDF files you will often find several options that you can use to compress or reduce the file size of your PDFs. It is worth taking advantage of these options, or using other PDF compression tools to reduce their file size.

    If you do compress PDF files (especially using other tools) you should check to make sure their formatting, layout and image quality is still satisfactory after you do.

If you can get your PDF files as low as 15MB or 25MB it should be fairly good. On the other hand if your PDF files start to approach 100MB or more then you're likely to want to look carefully at them.

Optimize for Search Engines

Just like any form of online content, you will want your PDF documents to be optimized for search engines. Fortunately that is one area that PDFs are actually surprisingly good at, as they have a lot of components that you can treat similarly to normal HTML documents.

When you want to optimize a PDF document for search engines, you should focus on:

  • Descriptive file names

    The file name of your PDF documents should reflect its contents, and ideally contain the main keyword you're targeting. Generally using the title and separating the words with dashes is the good option.

  • Title and description tag

    In every PDFs document properties there will be a title and description tag. Both tags will be used in the same way as their HTML counterparts and represent the text that appears in search results – and should contain keywords, particularly long-tail ones.

  • Other document properties

    Aside from the title and description there are several other document properties such as the author, keywords, and so on. While these may not have the same impact, it is worth filling them out regardless as they help contextualize your PDF document for search engines.

  • Alternate tags

    It is possible to add alternate text tags to images in your PDF documents, and you should take full advantage of that fact. Just like with webpages, search engines can't 'view' images the same way that people do, so providing them with text that describes the image can help.

If properly optimized, your PDF documents will be able to rank well on search engines. Generally search engines will treat PDF documents in the same way as HTML documents, and so the other factors that influence SEO such as keywords and backlinks will work in much the same way.

In short if you optimize your PDF documents for search engines, you should start to see them get listed and rank just as well as the rest of your online content.

Link To and Link From

As you probably know, PDF documents support hyperlinks – and you should take advantage of that. In particular you can use the hyperlinks to overcome one of the weaknesses of using PDF documents as online content, which is the fact that they tend to be 'isolated' from the website they're published on.

Unlike conventional HTML webpages nowadays that share the same common structure and are part of the Content Management System (CMS) in most cases – PDF documents do not share those elements. When visitors click on a link to a PDF file they are instead 'downloading' the PDF document and viewing it in their browser.

While you can't completely overcome this due to the fact that it is simply how PDF documents work – links can help you to make it less of a disadvantage. In particular you should make it a point to:

  • Link to your PDF documents in your website

    Rather than treating your PDF document as a 'download' you should link to it the same way you'd like to any normal webpage. If you want you can add a '(PDF)' excerpt of text to the title, to let readers know that they're about to open and view a PDF document.

  • Link back to your website from your PDF document

    Within your PDF document, you should try to link back to your website. If you want you could place hyperlinks as part of the content that links back to relevant pages on your website, but more importantly you should link back to your 'home'.

    One way to do that is to add a hyperlink in the header of every page of your PDF with the text 'Back to home' or 'Back to website'. That way readers will be able to quickly go back to your website, and the PDF will feel a little less isolated from it.

Another reason to establish a network of links to and from your website and PDF documents is because they will appear more as part of its content to search engines as well. That can help your PDF documents to get indexed faster, and give search engines more information regarding their context too.

Conclusion

As you can see there are lots of areas that should be optimized if you want to use PDF documents as online content. Some of the areas are easy, but others can be a bit more difficult to handle.

PDF editor

If you intend to use PDF documents as online content regularly, you may want to try using a simple PDF editor such as Movavi PDF Editor. It is a basic PDF editor that will let you add, remove, and rearrange pages in PDF documents, while also adding and adjusting images and performing other alterations. In short it is a pretty handy tool that will let you tweak your PDF documents and prepare them for online use.

For the most part it is best to regard PDFs as a particular type of online content. It is by no means ideal to replace all your HTML webpages with PDF documents, but adding a few PDF documents as content can be good.

To be entirely honest, using PDF documents as online content works best when it is an article or document that readers may want to download and save later. In that specific situation, the fact that the content is in PDF format will benefit readers as it will make it more convenient for them.

Still, now that you are aware of what you need to do to optimize and use PDFs as online content – you should be able to publish it and make sure it caters to both search engines as well as readers.

Let me know if you have any queries related to this interesting guide on PDF SEO. :)

Wednesday, February 14, 2018

Show IP Address & Geolocation Of Website Visitors Via JavaScript

Show IP Address & Geolocation Of Website Visitors Via JavaScript

Link to My Blogger Tricks

Show IP Address & Geolocation Of Website Visitors Via JavaScript

Posted: 14 Feb 2018 04:57 AM PST

Privacy and freedom are two things no one can compromise for anything. From anonymous web browsing using VPN or proxy servers to anonymous electronic transactions via cryptocurrencies, online freedom is the biggest quest of internet users today.

show IP address using javascript

Achieving complete anonymity online is difficult but not impossible thanks to developers working hard to introduce new tools and apps every other day. I am sure you all know how to hide your IP address using a VPN server, Tor browser or any proxy server but what may seem more appealing to you would be understanding how can you find out your website visitor's IP addresses and geolocation using plain client-side JavaScript and HTTP API.

What is IP address?

IP address stands for Internet Protocol address which is a unique string of numbers separated by full stops that identifies each computer using the Internet Protocol to communicate over a distributed network.

IP address is a unique numerical address assigned to your computer by your Internet Service Provider (ISP). Every computer connected to internet has a unique IP and its internet activity can easily be tacked through its IP address.

At present you can easily retrieve useful client IP addresses using WebRTC that is supported by browsers such as Firefox, Chrome and Opera. But to fetch full details of a user's IP address there are tons of free services that provide a public HTTP API.

These APIs  uses a database of IP addresses that are associated to cities along with other relevant information like time zone, region, zip code, latitude and longitude.

How To Show Site Visitor IP address and Geolocation?

I am using the free HTTP API provided by freegeoip.net site. We will make a simple ajax call to freegeoip to fetch the JSON data and parse JSON as text in plain JavaScript. The data is requested from the server using XMLHttpRequest().

DEMO: A Yellow load bar will appear followed by a table displaying full details of your public IP address and geographical location.

Loading your location details, please wait.........

Liked it? Let's learn how to add this cool JS tool to your blogger blog or wordpress blog to show visitors data in real time.

You can show this IP table anywhere you want, may it be your blog post, a static page or blog sidebar.

  1. Copy the code below and paste it inside the HTML editor of your blog theme or blog editor
     <style>           
    #loaderip {margin:10px;padding:20px; background:yellow; font-size:30px; }
    table.custom, table.custom2{width:100%;font-family:helvetica;border-spacing: 0;border: 0px solid #bbb;}table.custom,table.custom th,table.custom td, table.custom2 th, table.custom2 td{border:1px solid #ddd;border-collapse:collapse}table.custom td, table.custom2 td{padding:15px; min-width:100px;}th{padding:7px 10px;text-align:left;font-family:oswald;font-weight:400; font-size:16px;}table.custom tr:nth-child(odd), table.custom2 tr:nth-child(odd){background-color:#f1f1f1}table.custom tr:nth-child(even), table.custom2 tr:nth-child(even){background-color:#fff}table.custom th{background-color:#333;color:#fff;border:1px solid #333}table.custom th:nth-child(even){background-color:#555}
    table.custom2 th{background-color:#7dc733;color:#fff;border:1px solid #6fc415}table.custom2 th:nth-child(even){background-color:rgba(111, 196, 21, 0.75)}
    table.custom2 td:nth-child(odd){font-family: oswald;width: 43%;}
    table.custom2 th:hover {background-color: #6fc415;}</style>


    <div id="loaderip">Loading your location details, please wait.........</div>
    <div id="demo"></div>

    <script>
    //Show IP address my mybloggertricks.com
    var hideloader = document.getElementById("loaderip");
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            var myip = JSON.parse(this.responseText);
            document.getElementById("demo").innerHTML = '<table class="custom" border="0" cellspacing="0" cellpadding="0" width="590"><tbody><tr><td colspan="2"><p align="center"><font size="3"><b>Your IP Address is ➔</b> </font><strong><font color="#008000" size="5">'+myip.ip+'</font></strong></p></td></tr><tr><td valign="top" width="295">Your Public IP</td><td valign="top" width="295">'+myip.ip+'</td></tr><tr><td valign="top" width="295">Country Code</td><td valign="top" width="295">'+myip.country_code+'</td></tr> <tr> <td valign="top" width="295">Country</td> <td valign="top" width="295">'+myip.country_name+'</td> </tr> <tr> <td valign="top" width="295">Region</td> <td valign="top" width="295">'+myip.region_name+'</td> </tr> <tr> <td valign="top" width="295"> City </td> <td valign="top" width="295">'+myip.city+'</td> </tr> <tr> <td valign="top" width="295">Region Code</td> <td valign="top" width="295">'+myip.region_code+'</td> </tr> <tr> <td valign="top" width="295">Zip Code</td> <td valign="top" width="295">'+myip.zip_code+'</td> </tr> <tr> <td valign="top" width="295">Time Zone </td> <td valign="top" width="295">'+myip.time_zone+'</td> </tr> <tr> <td valign="top" width="295">Latitude</td> <td valign="top" width="295">'+myip.latitude+'</td> </tr> <tr> <td valign="top" width="295">Longitude</td> <td valign="top" width="295">'+myip.longitude+'</td> </tr>  </tbody></table>';

            hideloader.style.display='none';     }
    };
    xmlhttp.open("GET", "https://freegeoip.net/json/", true);
    xmlhttp.send();

    </script>

  2. Save your theme and you are all done!

Feel free to use it in your development projects or apps. Do share your queries or feedback in the comment box below.

Stay tuned for our biggest research paper on anonymous peer-to-peer electronic currencies i.e. Bitcoin on our coming posts. A lot of exciting tutorials are on its way. :)