Call to undefined function mysql_error() in PHP5.4

I’m working on some old code which uses the mysql_error function. The function should be present in PHP5.4, and present but deprecated in PHP5.5.

However, I get a Call to undefined function mysql_error() fatal error when running the code in Local with PHP5.4 or PHP5.5. It works in PHP5.3 though.

Is there anything I can/have to do to enable the old style mysql functions in PHP5.4 and PHP5.5?

@rowatt,

PHP 5.4+ in Local is not compiled with the mysql extension. It’s only compiled with pdo_mysql and mysqli.

You may be able to compile the mysql extension as a shared extension for 5.4-5.6 by following the instructions here: How do I compile additional PHP extensions?

As I’m sure you know, the best solution is to switch to a non-deprecated function that way you’ll be able to use PHP 7 in the future :slight_smile:

Thank you for clarifying @clay .

I’m PHP7 and PDO all the way for anything I am developing, but it’s rather hard to update an old code base if I can’t run it in the first place! Thanks for linking to the instructions for adding in the extension - unfortunately I couldn’t get that to work. I got as far as the configure step not generating anything that looks like an error but then make gave lots of errors.

For this project, I’ve reverted to MAMP, at least until I get it PHP7 compatible, but thanks for the help.

1 Like

Hey there!

Our new Local v5 (and later) doesn’t require VirtualBox :tada: which means it’s way more reliable and faster to startup.

Join the Beta Testers group and try our latest beta that brings back Custom Environments and other various improvements: https://localbyflywheel.com/community/g/beta-testers

Once you’ve joined the Beta Testers group, download the latest beta here: https://localbyflywheel.com/community/t/local-beta-5-2-0/16344/2

Happy coding!