• Register
0 votes
23 views

Problem :

When I try to connect to the MySQL server from PHP, I see a below error:

“Deprecated: The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /path/to/filename.php on line 123”

The code on a referenced line is as below:

mysql_connect($server, $username, $password);

I am certain that my arguments are correct, and also exact code has been working for many years without a problem. So how can I fix my code?

7 5 2
3,870 points

1 Answer

0 votes

Solution :

As per your error message suggests, there are the two other MySQL extensions that you can consider: MySQLi and PDO_MySQL, either of which can be used by you instead of ext/mysql. Both have been in the PHP core since v5.0, so if you are using the version that is throwing above deprecation errors then you can very certainly just start using them right away means without any of the installation effort.

They differ slightly, but offer the number of advantages over your old extension including API support for the transactions, stored procedures and your prepared statements (thereby providing a best way to defeat the SQL injection attacks). It helped me and many other PHP developers like me.

9 7 4
38,600 points

Related questions

0 votes
1 answer 7 views
7 views
Hi, I have a small php project. I need a php class that will enable me to retrieve the information from a database so that I can display in a table as shown in this html code: <!DOCTYPE html> <html> <head> <title>List of Cars</title> </head> <body> <table> <tr> <th>Year</th> <th>Brand</ ... >AUDI Q2 2020</td> </tr> <tr> <td>2020</td> <td>Volvo</td> <td>Xc60 2020</td> </tr> </table> </body> </html>
asked Oct 11 azriel 530 points
0 votes
1 answer 8 views
8 views
What is the difference between Drop command and Delete command in MySQL?
asked Oct 10 sikandar 2.4k points
0 votes
2 answers 14 views
14 views
I need to know how to create a multiple choice quiz in PHP and MySQL
asked Oct 3 Daniel Anderson 4k points
0 votes
1 answer 6 views
6 views
We have a medical supplier company online based. we provide medicine to the customer on home delivery. So the customer need to put their age in our web application. Hence, we are going to integrate it in our web application. Can anyone here help us to integrate the code in our application?
asked Sep 15 Daniel Anderson 4k points
0 votes
1 answer 212 views
212 views
Problem : I am trying to learn the pSQL. I recently moved my Laravel App from the MySQL to pSQL. But now I keep on getting below error. &ldquo;The Response content must be a string or object implementing __toString(), "boolean" given.&rdquo; I have the API that was returning my promotion before but now it only returns the above error. Can anyone suggest me solution on above error ?
asked Feb 13 mphil 2.3k points