1
Good morning. My function is returning an error, but I don’t know what you mean, I used the Singleton standard to do, so I will post 2 codes:
<?php
class IndicadoDAO{
private $idIndicado;
private $nome;
private $email;
private $telefone;
private $curso;
public function getidIndicado(){
return $this->idIndicado;
}
public function getNome(){
return $this->nome;
}
public function getEmail(){
return $this->email;
}
public function getTelefone(){
return $this->telefone;
}
public function getCurso(){
return $this->curso;
}
public function setidIndicado($idIndicado){
$this->idIndicado = $idIndicado;
}
public function setNome($nome){
$this->nome = $nome;
}
public function setEmail($email){
$this->email = $nome;
}
public function setTelefone($telefone){
$this->telefone = $telefone;
}
public function setCurso($curso){
$this->curso = $curso;
}
}
?>
<?php
require_once('conexao.php');
require_once('indicadoDAO.php');
function inserirIndicado(indicadoDAO $indicado) {
try{
$sql = ("INSERT INTO indicado (nome, email, telefone, curso)
VALUES(:nome, :email, :telefone, :curso)");
$bau = Conexao::getConectar()->prepare($sql);
$bau->bindValue(":nome", $indicado->getNome());
$bau->bindValue(":email", $indicado->getEmail());
$bau->bindValue(":telefone", $indicado->getTelefone());
$bau->bindValue(":curso", $indicado->getCurso());
return $bau->exec();
} catch(PDOException $error){
echo ("Erro encontrado") . $error->getMessage();
}
}
?>
but when I call the function it gives error, code gives page that is wrong to follow:
<?php
require_once('conexao.php');
require_once('indicado.php');
require_once('participante.php');
$pdo = Conexao::getConectar();
$pdo->beginTransaction();
inserirIndicado();
inserirParticipante();
$pdo->rollBack();
?>
Error result: on line 4, talks that you pass no parameter in them //
Too few Arguments to Function inserirIndicate(), 0 passed in
Could someone explain to me what’s wrong on line 4?
Row 4: Insert Function) {
...
}
Its function
inserirIndicado
expects a parameter,inserirIndicado(indicadoDAO $indicado)
, but when you are calling her you do not inform her of your value.– Woss
But down in getNome() getEmail() etc, it would not pick up and save in $indicated?
– user126343