The mysql_result in mysqli

Many of you have run into a problem when you were working on some old legacy php script that you wanted to adapt to PHP 7 where mysql_ functions no longer work (since they are deprecated).

The new PHP 7 comes with two database drivers: MySQLi and PDO. The PDO supports many different databases while MySQLi supports only MySQL.

So you probably thought, I’m just going to replace all mysql_ functions with mysqli_ and it’s done. Well, I’ve got bad news for you. It won’t! Also this way is also not safe. So take your time and learn about the changes and how you can overcome them.

Continue Reading Tags: opcache win10 2019

How to convert physical Windows PC into a virtual machine

After 10 years of running my main desktop computer on Windows 7 – time has finally come to upgrade it to Windows 10. Along with some hardware upgrades that my computer needed, I also wanted to move to the Windows 10 since the support and updates for Windows 7 will be discontinued on January 14th 2020.

Also, my 10 year old Windows 7 PC had a lot of settings and pieces of data that I didn’t want to give up that easily, so I got an idea to make a copy of the current Windows 7 as a virtual machine, so in case I need anything I could just boot the virtual machine and within seconds go back to my Windows 7 setup with all access all data and settings.

Making the virtual machine out of my Windows 7 PC

First step was to make a bootable copy of my computer’s hard drive partitions. For this purpose I used Disk2vhd tool made by Microsoft. It’s a free tool and all I needed to do is just pick partitions I want to backup and tell it where to back that up.

Disk2vhd

Ideally, you would want back this up on another drive (so the backup process is quicker since one drive just reads, while other one is just writing). My C: partition was 250gb and it was roughly 45% full and the result was a Windows7.vhdx file of roughly 100 GB in size. That was copy of my Windows 7 PC installation in one big file.

Continue Reading Tags: convert your pc to a virtual machine windows

How to downgrade PHP 7.4 to PHP 7.3 on VestaCP running on CentOS 7

I installed VestaCP for a clien on a new dedicated server running CentOS 7. Once you get a server or VPS with CentOS 7 by default it has no PHP installed.

After you install VestaCP using their guide for some reason you’ll end up with PHP 7.4.0RC5.

$ php -v
PHP 7.4.0RC5 (cli) (built: Oct 29 2019 08:49:19) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0-dev, Copyright (c) Zend Technologies

I didn’t like that first time I saw it and after I tried using it like that but the errors would just start popping all over the place. Even with software that VestaCP installed, like phpMyadmin:

phpMyAdmin errors running on VestaCP with PHP 7.4

There were also some errors with some WordPress themes and plugins and it was just not looking right and I wanted to back to stable version of PHP 7.3 but VestaCP doesn’t offer such thing out of the box, so the only way was to remove PHP 7.4 and install PHP 7.3 manually from command line.

Here are the lines you need to execute:

yum install yum-utils -y
yum-config-manager --disable remi-php5*
yum-config-manager --disable remi-php74
yum-config-manager --disable remi-test
yum-config-manager --enable remi-php73
yum remove php php-* -y
yum install roundcube phpmyadmin -y
service httpd restart

After this the you sould have PHP 7.3 up and running:

$ php -v
PHP 7.3.11 (cli) (built: Oct 22 2019 08:11:04) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies

But two other problems arise: phpMyAdmina and RoundCube wembail are not working:

phpMyAdmin not working on VestaCP

I went to check the config files at /etc/httpd/conf.d/ folder and I have noticed duplicate files for phpMyadmin and RoundCube: beside standard .conf files there were also .conf.rpmsave files (old ones).

So I removed these new ones (.conf) and renamed these old ones back to new ones restarted web server and everything was working again. Please make sure that you know what you’re doing here. Instead of deleting these two files you might want to just rename them or move them somewhere in case you’ll need them later. So have that in mind!

So, this is what I have done:

cd /etc/httpd/conf.d/
rm phpMyAdmin.conf
rm roundcubemail.conf
mv phpMyAdmin.conf.rpmsave phpMyAdmin.conf
mv roundcubemail.conf.rpmsave roundcubemail.conf
service httpd restart

BONUS: How to install OPCache and improve your php performance on VestaCP

OPcache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request.

yum install php-opcache -y
service httpd restart

And now php -v confirms that OPCache is active and running:

$ php -v
PHP 7.3.11 (cli) (built: Oct 22 2019 08:11:04) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.11, Copyright (c) 1999-2018, by Zend Technologies

Tags: php downgrade 7 3, how to downgrade php 7 4 to 7 3, how to enable Opcache in php version 7 3 11, https://geektnt com/how-to-downgrade-php-7-4-to-php-7-3-on-vestacp-running-on-centos-7 html, osC running on PHP 7 3