How to Show Only Duplicate Values From an Array With PHP

If you have an array with duplicate values, sometimes you might need to show only non-unique elements. Here is a short code in PHP that will allow you to do this. <? $arr=array_map(“trim”, file(“file.txt”)); $nonuniq=array_unique(array_diff_assoc($arr, array_unique($arr))); ?> This will return unique array of duplicates. If you need to show all duplicated values, use this code. <? $arr=array_map(“trim”, file(“file.txt”));… Read More »

mysql_secure_installation – You Must Run it After MySQL Server Setup!

After a fresh MySQL server setup I always run mysql_secure_installation script.  It allows to tune several settings, related to MySQL security and it is strongly recommended for running on every server. Let me show you the output of this command and explain some steps that are performed. [root@hosted-by checkers]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS… Read More »

.htaccess File to Make Your Site Accessible via HTTPS Only

If you have a SSL certificate installed, you might want to force your visitors to use secure version of it. Sometimes you cannot modify httpd.conf, the only file that can resolve the issue is .htaccess. Let me paste the code below to help you set this up. RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} This code checks… Read More »

checking for DB4 major version… configure: error: Header contains different version – How to Solve

If you are trying to compile PHP on a 64-bit OS (e.g. CentOS 6.4), you can see various error messages. The only reason is the different location of libraries, that causes the configure script to break. Let me tell you about a popular fix for DB4 support, that is not enabled by default. I have tried to configure… Read More »

Netfirms Error 500 – Where to See Logs

If you have a website, hosted on Netfirms, you should have experienced the problem of getting Error 500 even if you have a PHP syntax error in your scripts. I have never seen such a strange solution to make all errors look like 500, but I think this is done because of security requirements. Anyway, if you need… Read More »