Sunteți pe pagina 1din 9

_CK_ SAYS… making bbPress (and WordPress) work better!

Home

C AT E G O R I E S
How to put MySQL functions back into PHP 7 ajax
bbPress
PHP 7 will go “release candidate” on August 20th 2015 which is very exciting because it will instantly be twice CSS
as fast as PHP 5.6 (and all previous versions). PHP7 gives HHVM a run for the money and takes 5 minutes to Firefox extensions
compile instead of hours for HHVM. Firefox fixes
free stuff
But there is a catch – if you have any legacy code that uses the mysql_* functions, they will stop working hardware
entirely in PHP 7. Not just a warning, not just deprecated, but gone, fatal. HHVM
javascript
However, it is easy to get them back without using a wrapper or modifying your code… linux
I wouldn’t plan on using this solution far past 2016 but it will keep your legacy code running in the meanwhile. mySQL
PHP
Simply compile the mysql function as a php pecl extension and add one line to your php.ini rambling
random stuff
First get the mysql extension source which was removed in March: random thoughts
https://github.com/php/php-src/tree/PRE_PHP7_EREG_MYSQL_REMOVALS/ext/mysql TalkPress
Uncategorized
Either: windows fixes
Wordpress beta
1 cd ext/
2 git clone https://github.com/php/pecl-database-mysql mysql --recursive WordPress Security
WP development
or WP fixes
WP performance
1 cd ext/
WP plugins
2 svn co https://github.com/php/php-src/tags/PRE_PHP7_EREG_MYSQL_REMOVALS/ext/m
WP security
or WP themes
http://pecl.php.net/package/mysql
(same code, same timestamp, now static and likely will never be updated again)

ARCHIVES
Then compile the code on your server:
Select Month
1 phpize
2 ./configure
3 make
4 make install

The “make install” should announce where it is copying mysql.so – copy that path. It will likely be
BLOGROLL
/usr/local/lib/php/extensions/no-debug-non-zts-20151012/ for PHP 7 but it could vary depending on your libertus
server setup.
Mark on Wordpress
Then edit your php.ini mysql dba Sherri
Somewhere either in the “Extensions” section or “MySQL” section, simply add this line:
Ryan Boren
1 extension = /usr/local/lib/php/extensions/no-debug-non-zts-20151012/mysql.so
Tempus Fugit Blog
(change path if needed)
Wordpress Podcast

Restart PHP and mysql_* functions should now be working again. Check your php error log if you have any WordPress.com
problems (should check it periodically anyway). You will also see the MySQL section back in your phpinfo
WordPress.org
page.

Alternately, compile the mysql support into the PHP binary


CSS
It is also possible to compile PHP with the mysql extension built right in, so you don’t need to change the
php.ini file – follow these instructions: CSS Beauty

CSS Pile
http://php.net/manual/en/install.pecl.static.php
CSS Vault
Basically you put the mysql source under ext/mysql then clear out any existing configure in the php source CSS Zen Garden
root and force buildconf to make a new configure. Then compile php including –with-mysql on the ./configure
command line. list of galleries

Style Gala
Note that PHP 7 deprecates several other functions and is more strict about other things like classes, so you
may need to tune your log to be less harsh about warnings. Unmatched Style

1
Privacyerror_reporting
& Cookies: This site=uses
E_ALL & ~E_STRICT
cookies. & to
By continuing ~E_DEPRECATED
use this website, &you
~E_NOTICE
agree to their use.
Close and accept
To find out more, including how to control cookies, see here: Cookie Policy
MYSQL Follow
But don’t ignore the warnings entirely because “deprecated” will one day turn into completely missing and fatal mysql dba Sherri
like mysql functions.

Loading...
Like
PHP
2 bloggers like this.
Drupal Chix

PHPWomen
Related Scripty Goddess
How to build HHVM 3.8 on CentOS 7 WordPress 4.3 benchmark: HHVM 3.9 vs
In "WP performance" PHP 7.0
In "HHVM" W O R D P R E S S B E TA

How to manually install the Zend wordcamp 2006- what’s new in WP 2.1
Optimizer Plus Opcode Cache on PHP 5.4
In "PHP"

WP DEVELOPMENT
This entry was posted on August 6, 2015. It was filed under PHP and was tagged with PHP, php 7, php7.
Wordpress functions cross-reference from RedAlt

Wordpress Hooks list


← →
Wordpress on the IRC

Wordpress roadmap
43 responses

Pingback: PHP 7.0 Final will ship November 12th 2015 | _ck_ says... WP EMAIL LISTS

WP “pros”
Pingback: Der PHP 7 Migration Guide - entwickler.de
WP hackers archive

WP testers archive
http://sourceforge.net/projects/mysqlwithmysqli/

December 8, 2015 at 5:21 am


WP PERFORMANCE

Reply Guide To Optimizing WordPress Servers » Connected


Anonymous Internet

Optimizing Wordpress Performance & Speed by Elliott


Back

Pingback: PHP7'ye güncelleme nasıl yapılır? Sencer.de: Weblog-Software Benchmark II

WP queries: a short review » LightPress


Pingback: Wordpress使用PHP7.0更新紀̄ - 某數's blog
WP-Cache & APC

thank you, it worked, i have mysql extension on php 7.0.3


WP PLUGINS
March 4, 2016 at 12:27 pm Lester Chan’s WP plugins

Weblog tools collection


Reply
Aurel Wordpress Anti Spam Image

Wordpress plugins database

WP-plugins direct download interface

In these wrappers all mysql and ereg functions are rewritten using mysqli and pcre
https://sourceforge.net/projects/mysqlwithmysqli/
WP THEMES
https://sourceforge.net/projects/ereg-using-pcre/
Alex King’s WP Theme collection
March 15, 2016 at 1:50 pm Template Monster Wordpress themes ($$$)
Gianluca
WP theme viewer (official)
Reply

Pingback: maegel-online.de - » Verwendung von MySQL Funktion in PHP 7

Search

You’re my personal Jesus Christ.


Thanks a lot! M E TA

Register
April 29, 2016 at 10:19 pm
Log in

Entries RSS
Reply
Comments RSS
Claver Moraes WordPress.com

I haven’t understand from the line:

Then compile the code on your server:

May 16, 2016 at 7:40 am


sabin maharjan
Reply

How to put MySQL functions back into PHP 7 for WINDOWS

May 31, 2016 at 7:15 am

Reply
Anonymous

These instructions are mostly meant for linux environments but if you knew
how to compile on Windows, in theory it should also work. Alternately you
could use the prebuilt php libraries for Windows from Jan-E on
apachelounge.com

_ck_
https://www.apachelounge.com/viewtopic.php?t=6359

They also include the mysql functions in their builds.

May 31, 2016 at 7:48 am

Reply

Thanks a lot. It works!

May 31, 2016 at 10:41 am

Anonymous

Really? You want to use mysql_* functions?

Nishchal Gautam
June 10, 2016 at 12:36 am

Reply

Pingback: Jak rozfungovat staré mysql_* funkce v PHP7 – Martin Janeček

Pingback: Alte MySQL-Extension unter PHP 7 verwenden « Kreativrauschen


Tested, works. Thanks a lot!!

July 29, 2016 at 3:46 am

Reply
Anonymous

it isn’t working for me..

make install perfectly worked. it gives output path like: /usr/lib/php/20151012. but i
don’t know to what path i should change in extension path in php.ini file.

the default was, extension=/path/to/extension/mysql.so

sandhya
August 27, 2016 at 4:16 am

Reply

can anyone please help?

August 27, 2016 at 5:26 am

Reply
sandhya

Wow, it helped me a lot, thx for this article!

October 31, 2016 at 2:53 pm

Reply
Ralph Metel

Thank you very much,

November 4, 2016 at 3:48 am

Reply
vivek

Thanks a lot!

November 26, 2016 at 1:54 pm

Reply
Hacking Tutorials

it’s work!!!
thank you so much. i’ve tried to resolve this problem by a week, but i didn’t.

i have changed from your tutorial the command ./configure in

antonio ./configure –with-php-config=/usr/bin/php-config


cheers
antonio

February 1, 2017 at 12:08 pm

Reply

Куплю Квартиру Севастополь еще

Севастополь Аренда Офисов

March 1, 2017 at 5:19 pm

Alinamib Reply

how to convert mysql code into mysqli quickly ? i have a site based on mysql

http://imeibook.com and not working now because i coded into mysql please
urgent help required

March 6, 2017 at 5:46 am


Waqas Naeem

Reply

Many thanks, this site is extremely practical.|

March 14, 2017 at 9:17 am

Reply
Zachary Mcclave

That’s amazing

I was thinking of creating a wrapper for it.

March 28, 2017 at 12:05 pm

Ahmad Reply

Hey there, this worked for me and it totally saved my life so much!! !!!! But, strange
thing when running PHP from the command line I still get the Call to undefined

function mysql_connect()

August 8, 2017 at 4:40 pm


Pierre

Reply

hey I figured it out!! there are 2 php.ini one under /etc/php/7.0/apache2 and

there is another for cli under /etc/php/7.0/cli. I just needed to add the extension line
in the cli php.ini as well and it made the extension work on php cli as well

August 8, 2017 at 5:01 pm


Pierre

Reply

The extension wasn’t working for me so


Garvit Jain I created a file

nano /etc/php.d/50-mysql.ini

with content

; Enable mysql extension module

extension=mysql.so

not it’s working THanks!

September 18, 2017 at 3:22 am

Reply

thanks, working with installled fengoffice

October 24, 2017 at 9:16 pm

Reply
Anonymous

Hey there,

I know it’s pretty sick to still use deprecated mysql_ext on PHP 7++ … but as i’m

stuck with a mega-old-mega-big Monolith PHP App I’m forced to do so (at least at
the moment until it get’s completely rewritten …)
Andreas S.

The App is working since years without Probs with PHP 7.0 – but now I try to
upgrade it to PHP 7.1 (or even 7.2 later) … but I got Problems compiling the old

mysql Ext with PHP 7.1

/dl/mysql/php_mysql.c: In function ‘zif_mysql_list_fields’:

/dl/mysql/php_mysql.c:1760:19: warning: assignment makes pointer from integer


without a cast [enabled by default]
if ((mysql_result=mysql_list_fields(mysql->conn, table, NULL))==NULL) {

Code:
if ((mysql_result=mysql_list_fields(mysql->conn, table, NULL))==NULL) {
php_error_docref(NULL, E_WARNING, “Unable to save MySQL query result”);

RETURN_FALSE;
}

/dl/mysql/php_mysql.c: In function ‘zif_mysql_fetch_lengths’:


/dl/mysql/php_mysql.c:2372:14: warning: assignment discards ‘const’ qualifier from

pointer target type [enabled by default]


if ((lengths=mysql_fetch_lengths(mysql_result))==NULL) {
Code:
if ((lengths=mysql_fetch_lengths(mysql_result))==NULL) {

RETURN_FALSE;
}

When I comment those Lines – it compiles fine and it works … but of course those
2 Functions making Problems …

Anyone here who could give me a Hint on how to fix those 2 Code Fragments to
get it to work with PHP 7.1?
thx
Andreas

February 5, 2018 at 7:15 am

Reply

I’m not using 7.1 yet but those two “errors” appear to only be warnings from

undeclared variable types now being caught by a better compiler – an


oversight but not fatal – does it finish compiling and run/pass tests?

February 7, 2018 at 3:34 pm


_ck_

Reply

unfortunately not really … also found our what the Problem is …


mysql_list_fields() was removed from mysqlnd … so no wonder it’s

not working anymore …

https://github.com/php/php-
Andreas S.
src/commit/398caf9336a5f6a71439969c7fd610bfaf522b93#diff-
48eed863ec9451a1280e0e2d1d8e45b0

As it’s getting harder to compile with every PHP Version I’ve gone
another way and used a mysql –> mysqli wrapper … took me some
Hours and everything was working fine with mysqli … even this is a
Project with some Million LOCs …

February 7, 2018 at 3:45 pm

I will be sure to follow your other websites. This article is a bit too
advanced for me so is there anything you’d recommend for those just

starting out? Thank you so much for clearifing that third point, I’ve
been really confused about that for a long time. I’m always
browsingon the internet for insights that will help me.
Learn Belize

December 20, 2018 at 2:27 am

Reblogged this on carasimpeldotcom.

April 25, 2018 at 5:57 am

Reply
itsystemid

Pingback: How get all values in a column using PHP? - ExceptionsHub

ilIO)”.,..,’)(

August 25, 2018 at 4:21 am

Reply
Jauh
Nice guide. I understand why they removed the mysql_query (etc) functions, but
for some legacy sites it is useful to be able to continue to use them.

September 28, 2018 at 1:03 pm

webdevetc Reply

I forgot to say – this worked today (for php7.2 on centos)

September 28, 2018 at 1:04 pm

Reply
webdevetc

Thanks Antonio you are right, I had to add the with php config option because my
Ubuntu came with php 7.2 but I switched to php 7.1 manually to run certain picky
Pierre-Verthume
Larivière frameworks. didnt work until I add the sudo ./configure –with-php-
config=/usr/bin/php-config
note I think the forum transforms two dashes into 1 long weird dash so if you copy
this and it does not work that might be why.

Also in my case it was a little more complex. I had switched php version and
/etc/alternatives my php pointed to 7.1 but both phpize and php-config still pointed
to 7.2 that made it not work. Had to update those 2 as well with:
sudo update-alternatives –set php-config /usr/bin/phpize7.1

sudo update-alternatives –set php-config /usr/bin/php-config7.1

Then was able to ./configure with the Antonio option and finally it worked for me!!
Dont forget to add the extension both for apache and cli php.inis!! so it will work in
php running from the command lines (maybe in cronjobs etc..)

February 14, 2019 at 11:16 am

Reply

This does not work on CentOS 7. First problem is dat you need to install php-
devel. Secondly, the resulting so file will not load: cannot open shared object file:
No such file or directory), /usr/lib64/php/modules/mysql.so
(/usr/lib64/php/modules/mysql.so: undefined symbol: mysqlnd_get_client_info)) in

Unknown on line 0
Bart Coninckx

May 15, 2019 at 4:21 pm

Reply

The solution is to install php-mysqlnd

May 15, 2019 at 5:05 pm

Reply
Bart Coninckx
Leave a Reply

Enter your comment here...

Blog at WordPress.com.

S-ar putea să vă placă și