The MySQL extension is deprecated and'll be removed in the future, what's the reason?

Source: Internet
Author: User
Tags deprecated
PHP extension MySQL mysqli

I configured on my Computer 2-plan-team this system, which is written in PHP, after configuration, open index.php, but the following problems: Php Deprecated:mysql_connect (): The MySQL extension is Deprecated and would be removed in the Future:use mysqli or PDO instead in E:\SERVER\2-PLAN-TEAM\INCLUDE\CLASS.DATENBANK.P HP on line 38
Source code for class.datenbank.php:

/*
* 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);
}
}
?>
I use the server is IIS, I would like to ask you heroes what causes the above problems, how to solve ah?


Reply to discussion (solution)

What version of PHP are you in?
The error message is that mysql_connect is obsolete and will be removed in the future, with mysqli or PDO instead.

You can change the error level to temporarily mitigate:
PHP.ini in order: Error_reporting=e_all & ~e_notice & ~e_deprecated
Remember to restart the server to take effect.

My PHP version is 5.5.3

What version of PHP are you in?
The error message is that mysql_connect is obsolete and will be removed in the future, with mysqli or PDO instead.

You can change the error level to temporarily mitigate:
PHP.ini in order: Error_reporting=e_all & ~e_notice & ~e_deprecated
Remember to restart the server to take effect.
Okay, I'll try.

I was so puzzled that I used PDO to build the object, and then the following line was mysql_connect!

This code wasn't written by itself.

I was so puzzled that I used PDO to build the object, and then the following line was mysql_connect!

This code wasn't written by itself.
I didn't write it, it's an open-source system, someone else wrote it.

  • 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.