0
After upgrading the php version from 5 to 7 the system does not open, the mysql_connect function was discontinued I tried using mysqli and could not make it work.
Error:
Fatal error: Uncaught Error: Call to Undefined Function mysql_connect() in /home/group501/public_html/support/includes/classes/conecta.class.php:53 Stack trace: #0 /home/group501/public_html/support/index.php(44): conexao->conecta('MYSQL') #1 {main} thrown in /home/group501/public_html/support/includes/classes/conecta.class.php on line 53
class.conecta.php
function conecta($BANCO){
if (strtoupper($BANCO) =='MYSQL') {
$this->con=mysql_connect(SQL_SERVER,SQL_USER,SQL_PASSWD)or die(mysql_error());
$this->db=mysql_select_db(SQL_DB,$this->con);
if ($this->con == 0){
$retorno = "ERRO DE CONEXÃO - SERVIDOR!<br>";
}
else if ($this->db == 0){
$retorno = "ERRO DE CONEXÃO - BANCO DE DADOS!<br>";
} else {
$retorno = "";
}
return $retorno;
}
}
function desconecta($BANCO){
mysql_close($this->con);
}
Then attempt to update
function conecta($BANCO){
if (strtoupper($BANCO) =='MYSQL') {
$this->con=mysqli_connect(SQL_SERVER,SQL_USER,SQL_PASSWD)or die(mysql_error());
$this->db=mysqli_select_db(SQL_DB,$this->con);
if ($this->con == 0){
$retorno = "ERRO DE CONEXÃO - SERVIDOR!<br>";
}
else if ($this->db == 0){
$retorno = "ERRO DE CONEXÃO - BANCO DE DADOS!<br>";
} else {
$retorno = "";
}
return $retorno;
}
}
function desconecta($BANCO){
mysql_close($this->con);
}
**Erro:**
Warning: mysqli_select_db() expects Parameter 1 to be mysqli, string Given in /home/group501/public_html/support/includes/classes/conecta.class.php on line 54
Warning: mysqli_set_charset() expects Parameter 1 to be mysqli, Object Given in /home/group501/public_html/support/includes/classes/conecta.class.php on line 55
Notice: Object of class mysqli could not be converted to int in /home/group501/public_html/support/includes/classes/conecta.class.php on line 56
Fatal error: Uncaught Error: Call to Undefined Function mysql_query() in /home/group501/public_html/support/index.php:51 Stack trace: #0 {main} thrown in /home/group501/public_html/support/index.php on line 51
It would be interesting if you specify your question, in this format there is only one error and several codes.
– Tuxpilgrim
good morning, sorry, after upgrading the php version from 5 to 7 the system no longer opens the mysql_connect function was discontinued tried using mysqli and could not make it work.
– Vagner
@Vagner when using mysqli (most recent), you had another error or was the same error?
– Rodrigo Tognin
I updated the question with the update attempt.
– Vagner