Advertisement
Guest User

Untitled

a guest
Mar 31st, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. ;<?php
  2. ;die(); // /* No modificar sino sabe lo que hace */
  3. ;/*
  4. [database]
  5. driver="mysql"
  6. host="localhost"
  7. port="3306"
  8. schema="h_sancion"
  9. username="root"
  10. password=""
  11. ;*/
  12.  
  13. <?php
  14. $file = '__config.ini.php';
  15. $config = parse_ini_file($file, true);
  16. $host = $config['database']['host'];
  17. $user = $config['database']['username'];
  18. $pass = $config['database']['password'];
  19. $schema = $config['database']['schema'];
  20. class conexion extends mysqli
  21.  
  22. {
  23. public
  24.  
  25. function __construct($host, $user, $pass, $schema)
  26. {
  27. parent::__construct($host, $user, $pass, $schema);
  28. if (mysqli_connect_error())
  29. {
  30. die();
  31. }
  32. }
  33. }
  34.  
  35. $conexion = new conexion($host, $user, $pass, $schema);
  36. ?>
  37.  
  38. <?php
  39. $file = 'config.ini.php';
  40. $config = parse_ini_file($file, true);
  41. $host = $config['database']['host'];
  42. $user = $config['database']['username'];
  43. $pass = $config['database']['password'];
  44. $schema = $config['database']['schema'];
  45. $encode = $config['database']['encode'];
  46. class conexion extends mysqli
  47.  
  48. {
  49. public
  50.  
  51. function __construct($host, $user, $pass, $schema)
  52. {
  53. parent::__construct($host, $user, $pass, $schema);
  54. if (mysqli_connect_error())
  55. {
  56. die();
  57. }
  58. }
  59. }
  60.  
  61. $conexion = new conexion($host, $user, $pass, $schema);
  62. mysqli_set_charset( $conexion, $encode);
  63. ?>
  64.  
  65. ;<?php
  66. ;die(); // /* No modificar sino sabe lo que hace */
  67. ;/*
  68. [database]
  69. driver="mysql"
  70. host="localhost"
  71. port="3306"
  72. schema="bbdd"
  73. username="root"
  74. password="pass"
  75. encode="utf8"
  76. ;*/
  77.  
  78. /* cambiar el conjunto de caracteres a utf8 */
  79. if (!$mysqli->set_charset("utf8")) {
  80. printf("Error cargando el conjunto de caracteres utf8: %sn", $mysqli->error);
  81. exit();
  82. } else {
  83. printf("Conjunto de caracteres actual: %sn", $mysqli->character_set_name());
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement