0
I am trying to make every time the user clicks a button happen an UPDATE, but for some reason gives the No database selected, what’s wrong with that 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");
?>
Taskforce.phph -> Taskforce
  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");
}
$codigo=$tblDetalhes['codidoAtividade_TAREFA'];change to$codigo=$tblDetalhes[0]['codidoAtividade_TAREFA'];– NoobSaibot
Comment on the line
header("location:Atividade.php?codAtividade=$codigo");and below$sqlEditaSNyou create these lines for testing:echo $sqlEditaSN; die();then comment here the result that was printed on the page.– NoobSaibot