Themysqlextensionisdeprecatedandwillberemovedinthefuture. why?

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.