I've been at this for more than an hour now, I can connect to my database and all (doesn't give any errors) but i get the following error when i try to use "mysql_query($query);"
Call to undefined function mysql_query()
I've already tried enabling:
extension=php_mysql.dll
extension=php_mysqli.dll
and I've added:
extension_dir = "ext"
extension=php_mysql.dll
at the end of the import list.
Between every change I made I restarted all processes in exampp and after every single solution that I seperately tried it still gives this annoying error.
I've tried looking online, but the only error similar to mine would be:
Call to undefined function mysql_connect()
which at no point I've have had any issue with, never seen it.
I'm asking it here because I am being spammed on the google search results with the problem above; Not the one I am having.
I would be greatful if someone could help me with this, the tutorials I've found online show the exact same code that I have written.
PHP 7 has gotten rid of mysql_query()
because it's problematic in a variety of ways! The API does not encourage good practices, the official line is that it's unmaintained, and NO PREPARED STATEMENTS!?! It essentially is the biggest problem in PHP that encourages bad practices leading to sql injection, and that's a major big bad situation.
However, I do work with legacy codebases, so I have to deal with the same situation as you in some cases. If you have a small codebase, just update your db connection method. If you have a large codebase, here is what I recommend:
The answer is simple and this information has been available long before the release of PHP 7. It has been removed and they suggest to move over to mysqli or PDO. For a complete list of changes you need to know about for migration see this guide.
mysql_*
have been removed, meaning they are open to be redefined. You can create wrapper functions that refer to MySqli or PDO instead.mysql_*
functions provide just a piece of functionality of what MySQL really has to offer. (think about transactions, prepared statements, asynchronous queries, etc)I'm not saying that using MySqli or PDO will magically prevent MySQL injections but at least they provide native support against those kind of attacks. The rest is up to you; the programmer, to make sure to point data where it needs to go.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With