Why does not the object function call me and throw me error

0

The problem is that I want to use the fecth_array by calling the object and calling it what it shows is a message like this:
* Parse error: syntax error, unexpected 'public' (T_PUBLIC) in C: \ xampp \ htdocs \ www \ WEB Studios \ Studied Codes \ Prinick \ Prinick02 \ includes \ class.Conexion.php on line 12 *

   <?php

    class Acceso{
        protected $user;
        protected $pass;

        public function __construct($usuario,$password){
            $this->user = $usuario;
            $this->pass = $password;
        }

        public function Login(){
            $db = new Conexion();
            $sql = $db->query("SELECT nombre,password FROM usuarios WHERE nombre='$this->user' OR password='$this->pass'; ");
            $dato = $db->recorrer($sql);

            if(strtolower($dato['nombre']) == $this->user and strtolower($dato['password']) == $this->pass){
                session_start();
                $_SESSION['user'] = $this->user;
                header('location: acceso.php')

            }else{
                header('location: index.php?error=datos_incorrectos');
            }

        }

    ?>

class connection

<?php
    class Conexion extends mysqli{
        public function __construct(){
            parent::__construct('localhost','root','','prinick');
            $this->query("SET NAMES 'utf8';");
            $this->connect_errno ? die("Error de la Conexion"): $x = "SE Conecto";
            // echo $x;
            unset($x);
        }
    }

    public function recorrer($y){
        return mysqli_fetch_array($y);
    }
// $db = new Conexion();



?>
    
asked by Gamez 08.04.2017 в 03:57
source

1 answer

2

The problem is that you are closing the class and then you put the method, maybe the} you are forgetting that you closed it, try to remove it:

<?php
class Conexion extends mysqli
{
    public function __construct()
    {
        parent::__construct('localhost', 'root', '', 'prinick');
        $this->query("SET NAMES 'utf8';");
        $this->connect_errno ? die("Error de la Conexion") : $x="SE Conecto";
        // echo $x;
        unset($x);
    }


    public function recorrer($y)
    {
        return mysqli_fetch_array($y);
    }

}
?>

Although I think it should be return $y->fetch_array(); in the method to go through.

    
answered by 08.04.2017 в 04:37