Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
N

Nicolas Veloso

@Nicolas Veloso
About
Posts
2
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Fatal error: Uncaught Error: Call to a member function prepare() on null in
    N Nicolas Veloso

    Hello, I get this error when updating or editing data in a "name" field, I leave this error in more detail: Fatal error: Uncaught Error: Call to a member function prepare() on null in C:\xampp\htdocs\pdo\conectar.php:46 Stack trace: #0 C:\xampp\htdocs\pdo\editar.php(20): Datos->setDatos('update candidat...') #1 {main} thrown in C:\xampp\htdocs\pdo\conectar.php on line 46

    conectar.php:

    conn = new PDO("mysql:dbname=sistema\_votos;host=localhost", "root", "");
    } catch(PDOException $error){
    die("Error: ".$error);
    }
    return $this->conn;
    }
    public function setNames(){
    return $this->conn->query("SET NAMES 'utf8'");
    }
    }
    class Datos extends Conectar{
    private $bd;
    public function \_\_construct(){
    $this->bd = self::conectar();
    self::setNames();
    }
    public function getDatos($sql){
    $datos = $this->bd->prepare($sql);
    if (!$datos) {
    echo "\\nPDO::errorInfo():\\n";
    print\_r($this->bd->errorInfo());
    die();
    }
    $datos->execute();
    $this->bd=null;
    return $datos->fetchAll();
    }
    public function getDato($sql){
    $datos = $this->bd->prepare($sql);
    $datos->execute();
    $this->bd=null;
    return $datos->fetch();
    }
    public function setDatos($sql){
    $datos = $this->bd->prepare($sql);
    $datos->execute();
    //return $this->bd->lastInsertId();
    }
    }

    editar.php

    conectar.php:

    conn = new PDO("mysql:dbname=sistema\_votos;host=localhost", "root", "");
    } catch(PDOException $error){
    die("Error: ".$error);
    }
    return $this->conn;
    }
    public function setNames(){
    return $this->conn->query("SET NAMES 'utf8'");
    }
    }
    class Datos extends Conectar{
    private $bd;
    public function \_\_construct(){
    $this->bd = self::conectar();
    self::setNames();
    }
    public function getDatos($sql){
    $datos = $this->bd->prepare($sql);
    if (!$datos) {
    echo "\\nPDO::errorInfo():\\n";
    print\_r($this->bd->errorInfo());
    die();
    }
    $datos->execute();
    $this->bd=null;
    return $datos->fetchAll();
    }
    public function getDato($sql){
    $datos = $this->bd->prepare($sql);
    $datos->execute();
    $this->bd=null;
    return $datos->fetch();
    }
    public function setDatos($sql){
    $datos = $this->bd->prepare($sql);
    $datos->execute();
    //return $this->bd->lastInsertId();
    }
    }

    I'm desperate, because I can't find the solution, add that I've tested the connection and with respect to that everything works fine, so it's not a connection problem.

    Linux, Apache, MySQL, PHP database help php mysql data-structures

  • How to insert roles in php and mysql?
    N Nicolas Veloso

    Hello good, I have a query, what happens is that I want to enter user roles in my code but I don't know how to do it, I have the registration and login form already created, I just need to add the reference that I already mentioned above: register_user_be.php:

    1. {
      echo '
      alert("Este correo ya está registrado");
      window.location = "../index.php";
      ';
      exit();
      }

    //Verificar que el nombre de usuario no se repita en la bd

    $verificar_usuario = mysqli_query($conexion, "SELECT * FROM usuarios WHERE usuario='$usuario' ");
    if (mysqli_num_rows($verificar_usuario) > 0) {
    echo '
    alert("Este usuario ya está registrado");
    window.location = "../index.php";
    ';
    exit();
    }

    $ejecutar = mysqli_query($conexion, $query);
    if ($ejecutar) {
    echo '
    alert("Usuario registrado correctamente");
    window.location = "../index.php";
    ';
    }else{
    echo '
    alert("Inténtalo de nuevo, usuario no registrado");
    window.location = "../index.php";
    ';
    }

    mysqli_close($conexion);

    ?>

    login_usuario_be.php:

    1. {
      $_SESSION['usuario'] = $correo;
      header("location: ../inicio.php");
      exit;
      }else{
      echo '
      alert("El usuario no existe, por favor verifique los datos introducidos");
      window.location = "../index.php";
      ';
      exit;
      }

    ?>

    index.php:

    Web Development database php mysql tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups