What’s wrong with this code?

Asked

Viewed 31 times

-1

Where am I missing when updating this code to php 7.4.

File "controls/connected.php"

<?php 
// DADOS DA HOSPEDAGEM 
$endereco = "localhost"; 
$usuario = "root"; 
$senha = ""; 
$banco = "teste";

// CONEXÃO DASHBOARD
$link = mysqli_connect($endereco, $usuario, $senha);
mysql_select_db($banco, $link);
?>

"Dashboard.php"

<?php
include("controles/conexao.php");

//BUSCAR USUARIO
$buscarusuario = mysqli_query("SELECT * FROM usuario WHERE estado_usuario = 0  AND vendedor = 1", $link);

//PEGAR QUANTIDADE
$num_rows = mysqli_num_rows($buscarusuario);

//MOSTRAR QUANTIDADE
echo "$num_rows\n";
?>
  • The function mysql_select_db() has been removed since version 7.0.0

  • What function has the sub-institution?

  • https://www.php.net/manual/en/mysqli.select-db.php

  • https://www.w3schools.com/php/func_mysqli_select_db.asp

  • https://www.w3schools.com/pHp/func_mysqli_num_rows.asp

  • How could I leave this working code?

  • Fia the quick response right here, have to review

  • see also https://i.stack.Imgur.com/Ogbxr.png

  • for a quick view of https://answall.com/tour

Show 4 more comments

1 answer

0


The function mysql_select_db() has been removed since version 7.0.0

File "controls/connected.php"

<?php 
// DADOS DA HOSPEDAGEM

$endereco = "localhost"; 
$usuario = "root"; 
$senha = ""; 
$banco = "teste";

$link = new mysqli($endereco, $usuario, $senha, $banco);

// Check connection
if ($link->connect_error) {
  printf("Conexão falhou: " . $link->connect_error);
  exit();
}

?>

"Dashboard.php"

<?php
include("controles/conexao.php");

//BUSCAR USUARIO
$buscarusuario = ("SELECT * FROM usuario WHERE estado_usuario = 0  AND vendedor = 1");

//PEGAR QUANTIDADE
$result = mysqli_query($link, $buscarusuario);

//MOSTRAR QUANTIDADE
echo mysqli_num_rows($result);
?>
  • The reward is being able to help you! :-)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.