Having installed PHP7 can i also use php5_module along? - php

I just upgraded from php5.6. => php7.2.5
All of my websites are working except one that it only workd correctly with the php5_module and not with the php7_module.
Is there soem way to only have installed php7.2.5 but also use the php5_module as well?
This the error iam getting from a domain when i upgraded from php56 => php72
[Mon May 21 10:33:21.490109 2018] [proxy_fcgi:error] [pid 19775] [client 66.249.66.193:39398] AH01071: Got error 'PHP message: PHP Fatal error: Uncaught Error: Call to undefined function split() in /home/akis/public_html/wp-content/themes/business_for_sale_1-1/library/misc.php:19\nStack trace:\n#0 /home/akis/public_html/wp-content/themes/business_for_sale_1-1/library/navigation.php(271): theme_trim_long_str('\xCE\x91\xCF\x81\xCF\x87\xCE\xB9\xCE\xBA\xCE\xAE', '45')\n#1 /home/akis/public_html/wp-content/themes/business_for_sale_1-1/library/navigation.php(343): theme_MenuItem->get_start(0)\n#2 /home/akis/public_html/wp-content/themes/business_for_sale_1-1/library/navigation.php(315): theme_MenuWalker->display('', Array)\n#3 /home/akis/public_html/wp-content/themes/business_for_sale_1-1/library/navigation.php(92): theme_MenuWalker->walk(Array, Array)\n#4 /home/akis/public_html/wp-content/themes/business_for_sale_1-1/library/navigation.php(17): theme_get_list_menu(Array)\n#5 /home/akis/public_html/wp-content/themes/business_for_sale_1-1/header.php(62): theme_get_menu(Array)\n#6 /home/akis/public_html/wp-includes/template.php(688...\n'

Your error states:
Call to undefined function split()
After a quick google search I found this article in the PHP documentation:
http://php.net/manual/en/function.split.php
Warning. This function was DEPRECATED in PHP 5.3.0, and REMOVED in PHP 7.0.0.
Alternatives to this function include:
preg_split()
explode()
str_split()
Please conciser using one of the alternatives.
This is why you shouldn't use deprecated functions when writing code, because they will soon disappear and your code will crash when upgrading versions.

Yeah.. why not, you can have both versions installed. And you can enable or disable your PHP versions using the below commands if your are on a linux machine (ubuntu)
sudo a2dismod php7.2 (**Replace it with your PHP7 version**)
sudo a2enmod php5.6 (**To enable your PHP5.x version**)
sudo service apache2 restart (**Restart Apache**)
Again, if you want to enable 7.2 just replace it vice versa.
Note : Remember though, you can't have both versions working at the same time.

I think you can give https://github.com/cfebs/phpvm a go, this works well with my local environment.
Another option is to use Docker, create a container with both PHP versions and put your app into those containers to compare. Another good thing with a docker is that you can change docker-compose file to a version that suits you best.

Related

I can't use MySQLi in my ubuntu server. mysqli_fetch_all() is not defined?

A few days ago I made the migration from Windows to Ubuntu as my server. I've been doing pretty well but I've had problems with Apache since day one.
I've finally gotten somewhere, but now I'm stuck at this problem with using a MySQLi method in my PHP log (in /var/log/apache2):
[Tue Jul 14 19:23:15.326084 2015] [:error] [pid 16858] [client 71.76.17.180:59078] PHP Fatal error: Call to undefined function mysqli_fetch_all() in /var/www/hausofalexander.ml/index.php on line 6
In phpinfo() MySQLi is showing as enabled. You can see the info at http://www.hausofalexander.ml/info.php.
I am completely lost. If you need some more info just ask. Thanks!
As Hobo Sapiens points out in the comment the function/method mysqli_fetch_all() is only available if the mysqlnd library is used.
I'm not an Ubuntu guy, but you might try
sudo php5enmod mysqlnd
and if this seems to work (no obvious error message) restart the httpd and then check the output of phpinfo() for a mysqlnd section.
Available only with mysqlnd
if you use PHP version under 5.4.0 , you should install the mysqlnd
http://php.net/manual/en/mysqlnd.install.php
sorry for brevious answer it was totally wrong

Error loading PHP 5.5 Module into Apache 1.3 (OpenBSD version) on OpenBSD 5.6 platform

I am trying to configure a server using Apache 1.3 (apache-httpd-openbsd) , PHP 5.5 and MySQL on an OpenBSD 5.6 machine.
The problem occurs when i try to load the PHP module into Apache. I have added the following line in my httpd.conf file:
LoadModule php5_module /usr/local/lib/php-5.5/libphp5.so
The problem is that when i try to load this file by using
apachectl start
I get a bunch of errors like this:
/usr/local/sbin/httpd:/usr/local/lib/php-5.5/libphp5.se: undefined symbol 'apr_bucket_eos_create'
It seems that the PHP library refers to APR methods in Apache that should be included in the Apache distribution that i have. How can i help PHP to find those methods and be able to run on my server?
I found the issue and the solution.
After investigating my configuration further I noticed I had the Apache 2 version of PHP installed (php-5.5.14p0-ap2) instead of the correct 1.x one (php-5.5.14p0). APR in the 1.x versions of Apache uses "ap_" instead of "apr_" in their method signatures which was the cause of the problem.

Homebrew PHP5.5 failures OSX

I am on OS X 10.9.5.
I installed Php 5.5 via homebrew and also the PHP 5.5 mcrypt extension, php55 and php55-mcrypt in homebrew. In order to enable php5 in apache, I added this to /etc/apache2/httpd.conf
LoadModule php5_module /usr/local/opt/php55/libexec/apache2/libphp5.so
I'm using Laravel and need the Mcrypt extension, so I added this to /usr/local/php/5.5/php.ini
extension=mcrypt.so
In order to force the terminal to use the proper PHP version, 5.5, rather than the 5.4 the computer shipped with, I renamed /usr/bin/php to /usr/bin/php-old, and now the terminal falls back to /usr/local/bin/php, which is the version 5.5 that I'd like to use. Now, I am getting the following error in the terminal whenever I do anything in php from terminal.
[Sat Sep 20 16:32:12 2014] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/Cellar/php55/5.5.17/lib/php/extensions/no-debug-non-zts-20121212/mcrypt.so' - dlopen(/usr/local/Cellar/php55/5.5.17/lib/php/extensions/no-debug-non-zts-20121212/mcrypt.so, 9): image not found in Unknown on line 0
Any ideas on how this happened or where I went wrong? I'm getting discouraged by this OSX development server setup and considering just giving in and installing a dual-booted Ubuntu Partition. I was hoping to leverage OSX's unix base, but it has been a nightmare to setup the dev server so far.
You seem to have messed with homebrew since your PHP is looking for files in Cellar. Run "which php" and check which PHP is actually running and run "php --ini" to make sure you edited the right PHP configuration.
The easiest way to get a proper running PHP is to install it from Homebrew and add that to your PATH.

pg_connect undefined function on osx mavericks

I have looked at multiple SO threads and none of them seem to have my problem. I have compiled and install the pro_pgsql extension as outlined here: http://blog.rupey.org/post/63221360055/adding-postgres-support-to-php-on-os-x-mavericks and verified that it is loaded by running php -m apache has been restarted, php_info shows the following:
But when I run this script:
echo "hi!";
$ebdb_conn = pg_connect('dbname=mydb user=frank password=frank123') or die(pg_last_error());
I get the following error in the log:
[Mon Jun 09 12:39:05 2014] [error] [client ::1] PHP Fatal error: Call to undefined function pg_connect() in /Users/frank/Code/ebus/test.php on line 4
This is on OSX Mavericks, with Apache and PHP 5.2.24. Any ideas?
This problem was eventually solved by uninstalling everything that had to do with the Enterprise DB postgres package and reinstalling it with a consistent set of packages. I still, unfortunately have a non-matching psql client on the machine but other than that it is working fine. For others seeing this, I recommend:
DO NOT use enterprise DB installer found on the postgres website on OSX Mavericks use one of the following
1) postgres app (http://postgresapp.com) nice because its has postGIS and other extensions built in
2) map ports packages (https://trac.macports.org/browser/trunk/dports/databases/postgresql82/Portfile)
3) brew installer (http://www.moncefbelyamani.com/how-to-install-postgresql-on-a-mac-with-homebrew-and-lunchy/)
pg_connect isn't a part of the PDO library. It's contained in the direct postgresql library for PHP. In MacPorts, that's php5-postgresql, which macports gets from http://lil.fr.packages.macports.org/php5-postgresql.

Cannot install PDO on CentOS

I know there is several instances of this question throughout stackoverflow but I am not finding a solution.
I am running CentOS with Apache and PHP 5.3
A .php script is giving me this error:
Fatal error: Class 'PDO' not found in ...
I ran phpinfo(); and the only place "pdo" exists on the page is in the "Configure Command" '--disable-pdo' line.
I attempted #yum install php-pdo but no packages exist.
I also attempted #pecl install pdo and i get these errors at the end:
/root/tmp/pear/PDO/pdo_dbh.c: In function 'pdo_stmt_instantiate':
/root/tmp/pear/PDO/pdo_dbh.c:410: error: 'zval' has no member named 'refcount'
/root/tmp/pear/PDO/pdo_dbh.c:411: error: 'zval' has no member named 'is_ref'
/root/tmp/pear/PDO/pdo_dbh.c: In function 'pdo_stmt_construct':
/root/tmp/pear/PDO/pdo_dbh.c:435: error: 'zend_fcall_info' has no member named 'object_pp'
/root/tmp/pear/PDO/pdo_dbh.c:458: error: 'zend_fcall_info_cache' has no member named 'object_pp'
/root/tmp/pear/PDO/pdo_dbh.c: In function 'zim_PDO_setAttribute':
/root/tmp/pear/PDO/pdo_dbh.c:752: error: 'zval' has no member named 'refcount'
/root/tmp/pear/PDO/pdo_dbh.c: In function 'zim_PDO_getAttribute':
/root/tmp/pear/PDO/pdo_dbh.c:818: error: 'zval' has no member named 'refcount'
/root/tmp/pear/PDO/pdo_dbh.c: In function 'pdo_hash_methods':
/root/tmp/pear/PDO/pdo_dbh.c:1122: warning: assignment discards qualifiers from pointer target type
/root/tmp/pear/PDO/pdo_dbh.c:1126: warning: assignment discards qualifiers from pointer target type
make: *** [pdo_dbh.lo] Error 1
ERROR: `make' failed
Then on the php.net doc it basically says the package comes standard in php installations since PHP 5.1.
I added the line extension=pdo.so to php.ini and restarted Apache and the problem persists. Any suggestions?
I too have had a similar issue. I am using codeigniter and was getting a "pdo_mysql.so not found" error and tried everything to fix it. I must of searched thru the first 10 pages of google search results for multiple queries. I found tons of people with the same problems but for some reason none of them had an answer/fix. Thru all this reading I learned that "PDO and the PDO_SQLITE driver is enabled by default as of PHP 5.1.0." This got me thinking, "Perhaps I should remove the extension=pdo_mysql.so and pdo.so lines from my php.ini!" I figured php was trying to load an extension that was no longer there since it comes built in now. Sure enough, solved all my php error mess.
PHP 5.4.31 (cli) (built: Aug 19 2014 10:38:48)
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
Server version: Apache/2.2.27 (Unix)
Server built: Aug 19 2014 10:33:30
Cpanel::Easy::Apache v3.26.5 rev9999
I'm pretty sure that you're missing the PHP_PDO package. Try to find the PDO package by running the command bellow:
# rpm -qa| grep "pdo"
Mine shows php53u-pdo-5.3.26-1.ius.el5
If you are using php 5.3 then try
# yum install php53u-pdo
I dont know if it is too late for the answer, but I'll post if someone finds this error.
First, I had installed php-pdo in Centos 7 with yum. I viewed phpinfo and it shows the pdo extension but not pdo-mysql.
So, If you then installs php-mysql (yum install php-mysql) it will install automatically the pdo-mysql extension.

Categories