Forum Moderators: open

Message Too Old, No Replies

MYSQL Depreciated Error

         

captainron19

11:55 am on Jul 20, 2020 (gmt 0)

10+ Year Member



First of all I have no knowledge on MYSQL really but a friend created a database for me. I did do some updates to my server recently and ever since then an admin form I use on my website to select a category for a trivia question shows the following error on the form itself reading...


Deprecated: mysql(): This function is deprecated; use mysql_query() instead in /home/PATH-TO-PHP-FILE on line 116

The admin area still works but how do i remove this error?
The Database still works properly and pulls the data like it should for each day's new trivia question

not2easy

12:27 pm on Jul 20, 2020 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Can you take a look at the file and see what is on "line 116"? It would help to know the version of PHP in use because it has gone through a few transitional evolution steps over the past few years.

captainron19

12:37 pm on Jul 20, 2020 (gmt 0)

10+ Year Member



Line 116 reads...
$catResult = mysql("$db", "select * from category ORDER BY name");

The PHP Version in use is 5.4.45

DaveWave

10:04 pm on Jul 28, 2020 (gmt 0)

10+ Year Member



This is not an error, this is a message telling you that you are using an out of date function. You can change this by editing php.ini or adding a statement at the top of your script. I suspect you either upgraded from an earlier version of php or changed the php.ini file etc to show warnings.

Because the version of php you are using is 5 years out of date and you should really be using the mysqli library as mysql isn't supported in php 7.x. It's not a big job as most function names are replaced with similar names eg mysql_query() becomes mysqli_query()

If you want to update your site I'd recommend updating your database commands to use mysqli with your current version of php 5.4 and then move to the latest version of php that you can.

nordberg25

10:39 am on Aug 9, 2020 (gmt 0)

5+ Year Member



You can change the line to get rid of the error in the meantime to

$catResult = mysql_query($db, "SELECT * FROM `category` ORDER BY 'name'");


but please update to mysqli_query as much as I hate to even put mysql_query in that code I believe you would be mixing mysql and mysqli in the mean time which with throw other errors.

iamlost

6:26 pm on Aug 9, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes, please update all unpatched non updated software especially PHP, which has over 100 known vulnerabilities in the versions between latest and yours. Being ripe for being cracked is not a good place.