I was on a recent PHP project and found the need to get the domain name of the app I was building for. When I did some research I found that the main method I was using could become unreliable based on how a server is configured.
As it turns out
$_SERVER['HTTP_HOST'] might not be set. Since I’m building an application that has the requirement to run on many different servers, I had to make sure that I had a fallback if
$_SERVER['HTTP_HOST'] was not set.
To solve for this problem, we need to provide a fallback method. So the solution for the application I’m building ended up turning out like this.
$requestDomain = ($_SERVER['HTTP_HOST'])
Recently, I came across an issue when installing
mysql-server on Ubuntu 18.04. What I found is that after I installed
mysql-server using my standard approach of
sudo apt install mysql-server, and after running
mysql_secure_installation, my root user was denied access to MySql when trying to access with
mysql -u root -p. I would always get the following error:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
Continue reading “Tutorial – After Installing MySQL on Ubutnu 18.04, Fix “Access denied for user ‘root’@’localhost’” Error”
As a web developer, it can become frustrating sometimes to deal with 301 redirects when developing website. For example, when using localhost, some of your projects might force SSL. In most cases, when forcing SSL, web servers will send a 301 response along with the redirect headers to point the browser back to https:// requests.
Continue reading “Tutorial: Remove 301 Redirect from Browser Cache”
I was recently working on a project and found that I had to merge two very complex objects using PHP. I went to search for a solution and of course found
array_merge_recursively(). So naturally, I thought I would start out by converting my objects into arrays and using array_merge_recursively.
Continue reading “Tutorial: How to Recursively Merge Two Objects In PHP”
Recently, I had to figure out how to change <img> tag src using only PHP. I had to change the request from HTTP to HTTPS. I was given the task to convert a site over to HTTPS. The website is managed on Big Commerce. As we already know, when you are changing a site over to HTTPS, you have to hunt down all of the images/assets of the site and convert them to request HTTPS as well. Otherwise, you will end up with the dreaded, mixed-content error and your site is deemed as unsecured by the browser you are visiting your site from.
Continue reading “Tutorial: PHP Replace Img Src From String”
Gimp is a powerful image manipulation tool. It is very similar to Photoshop! If you have been using Gimp for any amount of time, you will already know its power. It an do most things that Photoshop is capable of. Compared to Photoshop, however, Gimp lacks some features that makes life so easy when you are creating beautiful images. For example, Gimp lacks native support for converting a standard RGB images to CMYK. It becomes more of a process with Gimp! In this tutorial, I will show you how to convert standard RGB images to CMYK.
Continue reading “Tutorial: How To Convert an Image Into CMYK Using Gimp On Ubuntu”