How to resolve Fatal error: Call to Undefined Function Contausuario() in

Asked

Viewed 1,721 times

0

In my case I have this function :

in the Home archive at the very beginning imported here:

    <?php

      require_once("session.php");

      require_once("class_usuario.php");
      $auth_user = new USER();


      $user_id = $_SESSION['user_session'];

      $stmt = $auth_user->runQuery("SELECT * FROM N00_Usuario WHERE idUsuario=:user_id");
      $stmt->execute(array(":user_id"=>$user_id));

      $userRow=$stmt->fetch(PDO::FETCH_ASSOC);

    ?>

    e no arquivo Home importei a classe que está dentro do arquivo Class_usuario:
    <?php

      require_once("session.php");

      require_once("class_usuario.php");
      $auth_user = new USER();


      $user_id = $_SESSION['user_session'];

      $stmt = $auth_user->runQuery("SELECT * FROM N00_Usuario WHERE idUsuario=:user_id");
      $stmt->execute(array(":user_id"=>$user_id));

      $userRow=$stmt->fetch(PDO::FETCH_ASSOC);

    ?>

<div class="box bg-primary">
                  <i class="fa fa-eye"></i>
                  <?php 

                  try{
                    $a= ContaUsuario($connection) ;
                  }

                catch(PDOException $e) {
    echo "Error: " . $e->getMessage();
}
                  ?>
                  <h3><?php echo $a;?></h3>
                  <p class="lead">Page views</p>
                </div>
              </div>

what’s wrong? Someone has an idea?

1 answer

1


Use your class and call the method.

try{
      $result =  $auth_user->ContaUsuario($connection);
      <h3><?php echo $result;?></h3>
 }
  • I’ll try to see what gives @Felipe

  • If it doesn’t work post here, I’ll try to find another way. @Gladiador

  • Then @Felipe the error contains. Maybe pq explained wrong. the function is in another file called Class_usuario and the part <H3><? php echo $a;? ></H3> is also in another Home file. I want to list the total number of registered users

  • Did you import the Class_usuario file? Can you post the Class_usuario code? @Gladiator If it is a php class you must instantiate an object in the class and call the method. $obj = new Class_Usuario();&#xA;$rows = $obj.ContaUsuario($connection);

  • I just posted the code . I edited it for you to see and if you can see anything wrong.

  • Is what you posted just the code from the Home file? @Gladiador

  • I posted the two comrade. on top is the class_usuario and at the end and the Home

  • 1

    @Gladiator mark as answered, this helps the community and others who come to see the question.

Show 4 more comments

Browser other questions tagged

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