Database Error

0

I'm trying to make every time the user clicks a button an UPDATE happens, but for some reason gives No database selected , what's wrong with this code?

Update.PHP

<?php
 require_once 'Classes/BancoDAO.php';
 $codTarefa=$_GET['codTarefa'];

require_once "Classes/TarefasVO.php";
require_once "Classes/TarefasDAO.php";

 $objTarefa = new TarefasVO();
 $objBDTarefa = new TarefasDAO();

$mysqli = new mysqli('localhost', 'root', '', 'bdpi');

$sqlDetalhes= "Select * from tarefas where codigo_TAREFA='$codTarefa'";
$rsDetalhes= mysqli_query($mysqli, $sqlDetalhes) or die (mysqli_error($mysqli));

$tblDetalhes=mysqli_fetch_array($rsDetalhes);

$status=($tblDetalhes['status_TAREFA']+1);

 $objTarefa->setCodigoTarefa($codTarefa);
 $objTarefa->setStatusTarefa($status);

  $objBDTarefa->EditaStatusTarefa($codTarefa, $objTarefa);

  $codigo=$tblDetalhes['codidoAtividade_TAREFA'];

   header("location:Atividade.php?codAtividade=$codigo");


?>

DAO.phph Tasks - > EditaStatusTarefa function

  public function EditaStatusTarefa($codTarefa,$tmp){

  $mysqli = new mysqli('localhost', 'root', '', 'bdpi');

   $sqlEditaSN= "Update tarefas set status_TAREFA=";
$sqlEditaSN.="'".$tmp->getStatusTarefa()."'";
$sqlEditaSN.=" where codigo_TAREFA = '$codTarefa'";

mysqli_query($mysqli,$sqlEditaSN) or die(mysqli_error($mysqli));

$sqlDetalhes= "Select * from tarefas where codigo_TAREFA='$codTarefa'";
$rsDetalhes= mysqli_query($mysqli, $sqlDetalhes) or die (mysqli_error($mysqli));

$tblDetalhes=mysqli_fetch_array($rsDetalhes);

$codigo=$tblDetalhes['codidoAtividade_TAREFA'];

header("location:Atividade.php?codAtividade=$codigo");

}
    
asked by anonymous 12.12.2017 / 03:33

1 answer

0

The problem is that you are not selecting the database. The way you made the connection is object oriented, but its query is in the procedural form.

Change this line:

$mysqli = new mysqli('localhost', 'root', '', 'bdpi');

To:

$mysqli = mysqli_connect('localhost', 'root', '', 'bdpi');

So your connection to the bank will also be procedural.

    
12.12.2017 / 04:22