Themysqlextensionisdeprecatedandwillberemovedinthefuture. why? Php extension mysql mysqli
I configured the 2-plan-team system on my computer, which was written in PHP. after the configuration, open the index. php: mysql_connect (): The mysql extension is Deprecated and will be removed in the future: use mysqli or PDO instead in E: \ server \ 2-plan-team \ include \ class. datenbank. php on line 38
Class. datenbank. php source code:
/*
* The class datenbank (database) provides methods to handle a database connection
*
* @ Author original code from Open Dynamics.
* @ Name datenbank
* @ Version 0.4.6
* @ Package 2-plan
* @ Link http://2-plan.com
* @ License http://opensource.org/licenses/gpl-license.php GNU General Public License v3 or later
*/
Class datenbank
{
/*
* Constructor
*/
Function _ construct ()
{
}
/*
* Establish a database connection
*
* @ Param string $ db Database name
* @ Param string $ user Database user
* @ Param string $ pass Password for database access
* @ Param string $ host Database host
* @ Return bool
*/
Function connect ($ db_name, $ db_user, $ db_pass, $ db_host = "localhost ")
{
// Mysql
// $ Db = new PDO ("mysql: host = $ db_host; dbname = $ db_name", $ db_user, $ db_pass );
$ Conn = mysql_connect ($ db_host, $ db_user, $ db_pass );
$ Db_check = mysql_select_db ($ db_name );
If ($ db_check)
{
Return true;
}
Else
{
Return false;
}
}
/*
* Wrap mysql_query function
*
* @ Param string $ str SQL search query
* @ Return bool
*/
Function query ($ str)
{
Return mysql_query ($ str );
}
}
?>
The server I use is IIS. What are the causes of the above problems? how can I solve them?
Reply to discussion (solution)
What is your php version?
The error message indicates that mysql_connect has been discarded and will be removed in the future. it will be replaced by mysqli or PDO.
You can change the error prompt level to temporarily mitigate the problem:
Php. ini: error_reporting = E_ALL &~ E_NOTICE &~ E_DEPRECATED
After modification, remember to restart the server to take effect.
My PHP version is 5.5.3
What is your php version?
The error message indicates that mysql_connect has been discarded and will be removed in the future. it will be replaced by mysqli or PDO.
You can change the error prompt level to temporarily mitigate the problem:
Php. ini: error_reporting = E_ALL &~ E_NOTICE &~ E_DEPRECATED
After modification, remember to restart the server to take effect.
Okay. let me give it a try.
I am wondering that I have used PDO to create objects, and the next line is mysql_connect!
This code is not written by yourself.
I am wondering that I have used PDO to create objects, and the next line is mysql_connect!
This code is not written by yourself.
It's not written by me. it's an open-source system. it's written by others.