registration with PDO

0

I have this error

Fatal error: Call to a member function prepare() on a non-object 

insertion code

$adam2=Conexion::conectar();


    $fech = $_POST['fech'];
    $hora = $_POST['hora'];
    $ced  = $_POST['ced'];
    $nom  = $_POST['nom'];
    $cargo = $_POST['cargo'];
    $fechRegistro = date('Y-m-d');

    // echo $nom;


    $registro = "INSERT INTO marcaje (fechEntrada, horaEntrada, cedula, nombre, cargo, horaRevista) VALUES (:fech, :hora, :ced, :nom, :cargo, :fechRegistro)";
    $resultado = $conn->prepare($registro);
    $resultado->execute(array(":fech"=>$fech, ":hora"=>$hora, ":ced"=>$ced, ":nom"=>$nom, ":cargo"=>$cargo, ":fechRegistro"=>$fechRegistro));

    echo "Registro Insertado";
    $resultado->closeCursor();

and this is the connection code

class Conexion {
         public static function conectar(){

        try{

          $conn=new PDO('mssql:host=192.168.20.219; dbname=Intranet', 'adam', 'pass');

          $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
          // $conect->exec("SET CHARACTER UTF8");




        }catch(Exception $e){

          die ("Error " . $e->getMessage());
          echo "Línea del Error " . $e->getLine();

        }

        return $conn;

      }

    }

Can you help me?

    
asked by Jdavid Barajas 09.05.2018 в 22:18
source

0 answers