• Register
0 votes
24 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

Please log in or register to answer this question.

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 41 views
41 views
Problem: How can we solve this problem? Is there any alternate solution?
asked Nov 19, 2020 prog_learner 2.5k points
0 votes
3 answers 25 views
25 views
Problem: How to resolve the warning : “__autoload() is deprecated, use spl_autoload_register() instead” in PHP.
asked Dec 17, 2020 prog_learner 2.5k points
0 votes
1 answer 22 views
22 views
Problem: Hi, kodlog i need assistance regarding this popup error message.” Your php installation appears to be missing the mysql extension which is required by wordpress.”
asked Nov 9, 2020 prog_learner 2.5k points
0 votes
1 answer 39 views
39 views
Problem: I am getting this error everytime I open my server. I need someone to help me how to remove this error?
asked Nov 14, 2020 prog_learner 2.5k points
0 votes
1 answer 66 views
66 views
Problem: Just to brief the title, I want to make a bar chart that will read data from a database table using MySql, and auto adjust the height to fit the new data. The data enters the database through the Arduino microcontroller, so data is repeatedly added ... data and increase its height according to it. Is there a way to do this without constantly refreshing the webpage every 0.5 seconds?
asked Dec 7, 2020 sasha 5.3k points
0 votes
1 answer 14 views
14 views
Question: How to select the csv file and then upload the content to mysql. Also, how to prevent the data from being duplicated in php. The field names of the csv is listed below. table: id name // cannot be duplicated talent // cannot be duplicated address email
asked Nov 2, 2020 RJ Lam 650 points
0 votes
1 answer 21 views
21 views
Issue: I have a project in mysql and php. It works but the thing is that it will keep on refeshing when I select the name. Also, it is so cumbersome to keep on clicking the submit button. Is there anyway to solve my issue that whenever I select the member's name, the table will refresh itself ... thead>     <tbody>         <tr>             <?php echo $table; ?>         </tr>     </tbody> </table> 
asked Oct 31, 2020 RJ Lam 650 points
0 votes
1 answer 12 views
12 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, 2020 azriel 590 points
0 votes
1 answer 17 views
17 views
What is the difference between Drop command and Delete command in MySQL?
asked Oct 10, 2020 sikandar 2.4k points
0 votes
2 answers 32 views
32 views
I need to know how to create a multiple choice quiz in PHP and MySQL
asked Oct 3, 2020 Daniel Anderson 4k points