Insert into does not return [closed]

1

I have the following table:

QuerywithInsert    

publicfunctionCadastrarArquivos($pdo,$arq_nome,$a_areaid,$u_userid){$ins=$pdo->prepare("INSERT INTO arq_arquivos(arq_nome, a_area_a_areaid, u_usuarios_u_useid) VALUES(:arq_nome, :a_areaid, :u_userid)"
            );
        $ins->bindParam(":arq_nome",$arq_nome);
        $ins->bindParam(":a_areaid",$a_areaid);
        $ins->bindParam(":u_userid",$u_userid);

    $obj = $ins->execute();

    return ($obj) ? $obj : false;<code>

// php function to register

function cadastrarArquivo($app){           

        $param = array("titulo"=>$app->site_titulo, 
                       "pagina" => "formarquivos",
                       "dados" => array(
                            "tituloform" => "Cadastrar novo Arquivo",
                            "action"=>"execCadastrarArquivo",
                            "arq_arqid"=>"",                                
                            "arq_nome"=>"",
                            "labelbtnsubmit"=>"Cadastrar"

                        )
                       );

        $app->loadView("Admin",$param);
    }

    function execCadastrarArquivo($app){
        $admin = $app->loadModel("Admin");


        $arq_nome = ($_POST["arq_nome"]);
        $a_areaid = 1;   /*marque 1 para selecionar uma area já existente de teste.*/
        $u_userid = $_SESSION["u_userid"];

        $obj = $admin->CadastrarArquivos($app->conexao, $arq_nome, $a_areaid,  $u_userid);

        if($obj) {
            $mensagem = "Cadastro efetuado com sucesso!";
        } else {
            $mensagem = "Cadastro falhou!";
        }

        $this->listarareainicial($app,$admin,$mensagem);
    }<code>

// This way you are not giving any error, but do not register in the bank.

html form

                             

<form method="POST" action="index.php?m=admin&c=minhaarea&a=<?=$tpl["dados"]["action"]?>"> <div class="row"> <div class="col-xs-2"> <strong>Nome do arquivo:</strong> </div> <div class="col-xs-10"> <input type="text" name="arq_nome" class="col-xs-12 form-control" value="<?=$tpl["dados"]["arq_nome"]?>" autofocus required /> </div> </div> <div class="row marginTop"> <div class="col-xs-2"> <input type="submit" value="<?=$tpl["dados"]["labelbtnsubmit"]?>" class="btn btn-primary btn-large" /> </div> </div> <input type="hidden" value="<?=$tpl["dados"]["arq_arqid"]?>" name="arq_arqid" /> </form>

    
asked by anonymous 19.03.2016 / 18:28

1 answer

0

Your problem seems to be in the $ins->bindParam(":a_areaid",$a_areaid); part. Put the parameter PDO::PARAM_INT , after $a_areaid in this way:

$ins->bindParam(":a_areaid",$a_areaid,PDO::PARAM_INT);

Use this parameter when passing an int value to the database.

More information at this link: link

    
19.03.2016 / 23:32