Fatal error: Uncaught Error: Call to Undefined Function idbancoExist() in

Asked

Viewed 65 times

0

I’m running bank records for one-page users. When performing the code test on localhost everything is working fine, but when I upload to the server I have it shows the error:

Fatal error: Uncaught Error: Call to undefined function idbancoExiste() in /home/u619105775/domains/airrocket.com.br/public_html/afiliados/minhaconta.php:23 Stack trace: #0 {main} thrown in /home/u619105775/domains/airrocket.com.br/public_html/afiliados/minhaconta.php on line 23

Follows the code:

<?php

session_start();
require 'funcs/conexion.php';
require 'funcs/funcs.php';

$errors = array();

if(!empty($_POST)){

$cpf =$mysqli->real_escape_string($_POST['cpf']);
$numero =$mysqli->real_escape_string($_POST['numero']);
$nomebanco = $mysqli->real_escape_string($_POST['nomebanco']);
$agencia =$mysqli->real_escape_string($_POST['agencia']);
$conta=$mysqli->real_escape_string($_POST['conta']);

$idUsuario = $_SESSION['id_usuario'];

if(cpfExiste($cpf))
    {
        $errors[] = "CPF ja existe";
    }
if(idbancoExiste($idUsuario))     <== LINHA DO ERROR
    {   
    $errors[] = "OOps, já existe um registro para este usuario."; 
    }

    $registro =registraCpf($cpf, $numero, $nomebanco, $agencia, $conta, $idUsuario);
        if ($registro) {
  header("location:minhaconta.php");
} 
}

Archivo funcs.php

function idbancoExiste($idUsuario)
{
    global $mysqli;

    $stmt = $mysqli->prepare("SELECT * FROM tbbancarios WHERE idusuario= ? LIMIT 1");
    $stmt->bind_param("i",$idUsuario);
    $stmt->execute();
    $stmt->store_result();
    $num = $stmt->num_rows;
    $stmt->close();

    if ($num > 0){
        return true;
        } else {
        return false;   
    }
}
  • Hello Everson, as the error informs, he is unable to find the function idbancoExiste, check the path that code require 'funcs/funcs.php'; is making.

  • @Good morning, I’ve checked the code. The localhost is all right, but when I publish the page, this error appears, I have already looked at the php version and made other tests and so far nothing. Would you have any other hints? I will check this function again.

  • I believe the problem is not in your function code but in the import made by require. Try to work with the path absolute and not relative, maybe it works.

  • @Gerep, I continue with the same error, I tried the absolute path this way: $pathFile = realpath('funcs'. DIRECTORY_SEPARATOR . 'funcs.php') ; if ($pathFile) { include($pathFile); } Else { echo 'Error: File not found! <br>'; echo 'Path: '. $pathFile . '<br>'; }

No answers

Browser other questions tagged

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