Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created June 24, 2020 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/262aa5a17bcf08ac3e9e8aab60e8e038 to your computer and use it in GitHub Desktop.
Save parzibyte/262aa5a17bcf08ac3e9e8aab60e8e038 to your computer and use it in GitHub Desktop.
<?php
$contraseña = "";
$usuario = "root";
$nombre_base_de_datos = "ventas";
try {
$base_de_datos = new PDO('mysql:host=localhost;dbname=' . $nombre_base_de_datos, $usuario, $contraseña);
$base_de_datos->query("set names utf8;");
$base_de_datos->setAttribute(PDO::ATTR_EMULATE_PREPARES, FALSE);
$base_de_datos->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$base_de_datos->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
} catch (Exception $e) {
echo "Ocurrió algo con la base de datos: " . $e->getMessage();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment