Mam taki kod od znaj i spytał się czy mogę mu go przepisać aby nie wyświetlał się błąd
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO
To jest kod
require_once $root.'/config.inc.php'; class Database { var $server = "localhost"; //database server var $user = "root"; //database login name var $pass = ""; //database login password var $database = ""; //database name var $pre = ""; //table prefix var $showerror = false; ####################### //internal info var $error = ""; var $errno = 0; //number of rows affected by SQL query var $affected_rows = 0; var $link_id = 0; var $query_id = 0; #-############################################# # desc: constructor function Database($database) { require_once $root.'/config.inc.php'; $this->server = DB_FORUMS_SERVER; $this->user = DB_FORUMS_USER; $this->pass = DB_FORUMS_PASS; $this->database = DB_FORUMS_DATABASE; $this->pre = DB_FORUMS_PREFIX; $this->server = DB_LOGS_SERVER; $this->user = DB_LOGS_USER; $this->pass = DB_LOGS_PASS; $this->database = DB_LOGS_DATABASE; $this->pre = DB_LOGS_PREFIX; $this->server = DB_SERVER; $this->user = DB_USER; $this->pass = DB_PASS; $this->database = DB_DATABASE; $this->pre = DB_PREFIX; } $this->showerror = DB_SHOW_ERROR; } #-#constructor() #-############################################# # desc: connect and select database using vars above # Param: $new_link can force connect() to open a new link, even if mysql_connect() was called before with the same parameters function affected_rows() { return $this->affected_rows; }
function connect($new_link = false) { // var_dump($this->server);die; if (!$this->link_id) {//open failed $this->oops("Could not connect to server: <b>$this->server</b>."); } $this->oops("Could not open database: <b>$this->database</b>."); } // Deprecated but will get us rolling with mysql 5.7 for now. $this->query("SET SESSION sql_mode = ''"); // unset the data so it can't be dumped $this->server = 'localhost - host name'; $this->user = 'root - user name'; $this->pass = 'pass'; $this->database = 'db - name'; }
Czytałem trochę o mysqli i PDO ale nie jestem w stanie mu tego zrobić i mam prośbę do was
Czy ktoś z was może mi to przepisać ?
PS: Jeśli chodzi o przepisywanie takiego kodu na przyszłość stosować PDO czy mysqli
