elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recuerda que debes registrarte en el foro para poder participar (preguntar y responder)


  Mostrar Mensajes
Páginas: [1] 2 3 4 5
1  Programación / PHP / Re: conectar a base de datos con objetos en: 10 Junio 2014, 14:53 pm
Código
  1. class DBHandler {
  2.  
  3.    private $link;
  4.    private $db_name;
  5.  
  6.    // On instance created connect to host
  7.    // For installation, database name is null
  8.    public function __construct($db_name = NULL) {
  9.       $this->db_name = $db_name;
  10.       $this->link = $this->connection($db_name);
  11.    }
  12.  
  13.  
  14.    private function connection() {
  15.        $this->link = @new mysqli(DB_HOST, DB_USER, DB_PASSWORD, $this->db_name);
  16.  
  17.        if($this->link)
  18.            return $this->link;
  19.        else
  20.            die('Couldnt connect to db: ' . $this->link->connect_error);
  21.    }
  22.  
  23.    private function disconnect() {
  24.        $this->link->close();
  25.    }
  26.  
  27.    public function __destruct() {
  28.        // Check if connection was established
  29.  
  30.        if($this->link != NULL)
  31.            $this->disconnect();
  32.    }
  33.  
  34. }

Recibo:
Citar
PHP Warning:  mysqli::close(): Couldn't fetch mysqli in includes/DBHandler.php on line 24

o sea en la linea:
Código
  1. $this->connection->close();
2  Programación / PHP / conectar a base de datos con objetos en: 10 Junio 2014, 14:10 pm
Soy un poco novato en esto asi que perdonen la pregunta. Porque en la funcion "disconnect", al hacer un llamado a la funcion close() (de mysqli) no responde?
Código
  1. class DBConnection {
  2.  
  3.    private $connection;
  4.  
  5.    // On instance created connect to db
  6.    public function __construct() {
  7.        $this->connect();
  8.    }
  9.  
  10.    private function connect() {
  11.        require_once 'db_config.php';
  12.        $this->connection = @new mysqli(DB_HOST, DB_USER, DB_PASSWORD);
  13.  
  14.        if(!$this->connection)
  15.            die('Couldnt connect to db: ' . $this->connection->connect_error);
  16.    }
  17.  
  18.    private function disconnect() {
  19.        $this->connection->close();
  20.    }
  21.  
  22.    public function __destruct() {
  23.        // Check if connection was established
  24.  
  25.        if($this->connection != NULL) {
  26.            $this->disconnect();
  27.        }
  28.    }
  29.  
  30. }
3  Sistemas Operativos / GNU/Linux / instalar arch con windows 8 en uefi en: 31 Julio 2013, 19:46 pm
alguno me puede echar un cable? si ya tengo una particion efi en mi sistema hecha por windows 8, tengo que crear otra para arch linux o puedo usar la misma? y como la re-uso? he isntalado tambien el rEfind (desde windows).
4  Programación / PHP / Re: Undefined variable en: 19 Julio 2013, 13:29 pm
pero tengo el mismo problema con una funcion:

Código
  1. <?php
  2. // Initialize variables
  3.  $name = $address = $email = $items = $success = "";
  4.  $error_name = $error_address = $error_email = $error_items = "";
  5.  
  6. function checkName($nombre) {
  7.  
  8.    if(empty($nombre))
  9.    {
  10.        $error_name = "Missing";
  11.    }
  12.    elseif (!preg_match('/^[a-zA-z]*$/', $nombre, $name_match))
  13.    {
  14.        $error_name = "Only alphabets  allowed";
  15.    }
  16.  
  17.    return $error_name;
  18. }
  19. if (isset($_POST['submit']))
  20. {
  21.    if($_SERVER['REQUEST_METHOD'] == "POST")
  22.    {
  23.    $name = $_POST['name'];
  24.    $address = $_POST['address'];
  25.    $email = $_POST['email'];
  26.    $item = array();
  27.  
  28.    // Verify input:
  29.    checkName($name);
  30.    }
  31.  
  32. }
  33. ?>
  34.  
  35. html........

Como es que no esta definida si esta arriba de la funcion?
5  Programación / PHP / Re: Undefined variable en: 19 Julio 2013, 10:23 am
gracias
6  Programación / PHP / Undefined variable en: 18 Julio 2013, 16:58 pm
Que anda mal aca?:

Código
  1. <form method="post" action="<?=htmlspecialchars($_SERVER['PHP_SELF'])?>"><fieldset><legend>Form</legend>
  2.  
  3. <label>Name:</label> <input type="text" size="15" name="name" value="<?=$name;?>" /> <span id="error">$nameErr</span>
  4. <input type="submit" name="submit" id="button" value="Send" /></form>
  5.  
  6.  
  7. <?php
  8. if (isset($_POST['submit']))
  9. {
  10.    // Initialize variables
  11.  $name = "";
  12.  
  13.  if ($_SERVER['REQUEST_METHOD'] == "POST")
  14.  {
  15.    if (empty($_POST['name']))
  16.    {
  17.        $nameErr = "Missing";
  18.    }
  19.    else
  20.    {
  21.        $name = $_POST['name'];
  22.    }
  23.  
  24.  }

Notice: Undefined variable: name in line...
7  Programación / PHP / Re: decodificar imagenes en: 17 Julio 2013, 22:19 pm
Pero como en el wamperserver le hizo sin poner el nombre de las imagenes??

No hay un file_get_contents("imagen.png")...
8  Programación / PHP / decodificar imagenes en: 17 Julio 2013, 21:47 pm
Quisiera saber como decodificar (y en principio como codificar) imagenes en base64.

Mi codigo es el siguiente:
Código
  1. $img_src = file_get_contents("IMG_0205.jpg");
  2.  
  3. $encode = base64_encode($img_src);
  4.  
  5. echo '<img src="data:image/jpg;base64,' . $encode . '" />';
  6.  

Ahora, si se fijan en el index.php del wampserver, no tiene la linea donde especifica el nombre de la imagen, simplemente esta asi:

Código
  1. $pngFolder = <<< EOFILE
  2. iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAA3NCSVQICAjb4U/gAAABhlBMVEX//v7//v3///7//fr//fj+/v3//fb+/fT+/Pf//PX+/Pb+/PP+/PL+/PH+/PD+++/+++7++u/9+vL9+vH79+r79+n79uj89tj89Nf889D88sj78sz78sr58N3u7u7u7ev777j67bL67Kv46sHt6uP26cns6d356aP56aD56Jv45pT45pP45ZD45I324av344r344T14J734oT34YD13pD24Hv03af13pP233X025303JL23nX23nHz2pX23Gvn2a7122fz2I3122T12mLz14Xv1JPy1YD12Vz02Fvy1H7v04T011Py03j011b01k7v0n/x0nHz1Ejv0Hnuz3Xx0Gvz00buzofz00Pxz2juz3Hy0TrmznzmzoHy0Djqy2vtymnxzS3xzi/kyG3jyG7wyyXkwJjpwHLiw2Liw2HhwmDdvlXevVPduVThsX7btDrbsj/gq3DbsDzbrT7brDvaqzjapjrbpTraojnboTrbmzrbmjrbl0Tbljrakz3ajzzZjTfZijLZiTJdVmhqAAAAgnRSTlP///////////////////////////////////////8A////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////9XzUpQAAAAlwSFlzAAALEgAACxIB0t1+/AAAAB90RVh0U29mdHdhcmUATWFjcm9tZWRpYSBGaXJld29ya3MgOLVo0ngAAACqSURBVBiVY5BDAwxECGRlpgNBtpoKCMjLM8jnsYKASFJycnJ0tD1QRT6HromhHj8YMOcABYqEzc3d4uO9vIKCIkULgQIlYq5haao8YMBUDBQoZWIBAnFtAwsHD4kyoEA5l5SCkqa+qZ27X7hkBVCgUkhRXcvI2sk3MCpRugooUCOooWNs4+wdGpuQIlMDFKiWNbO0dXTx9AwICVGuBQqkFtQ1wEB9LhGeAwDSdzMEmZfC0wAAAABJRU5ErkJggg==
  3. EOFILE;
  4.  
  5. ..............
  6.  
  7. if (isset($_GET['img']))
  8. {
  9.    switch ($_GET['img'])
  10.    {
  11.        case 'pngFolder' :
  12.        header("Content-type: image/png");
  13.        echo base64_decode($pngFolder);
  14.        exit();
  15.  

Y llama las imagenes (en css):
Código
  1.  
  2. background: url(index.php?img=gifLogo) 0 0 no-repeat;
  3.  


Alguien me puede decir como ahcer eso ?
9  Programación / PHP / Re: problemas con formato de imagen en: 16 Julio 2013, 20:50 pm
Me dice:string '' (length=0). Pense que era por elupload_max_filesize que estaba en 2MB y los archivos eran de +3MB, pero no es eso.
10  Programación / PHP / Re: problemas con formato de imagen en: 16 Julio 2013, 20:13 pm
Me sigue dando el mismo die().

Como se puede falsificar???
Páginas: [1] 2 3 4 5
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines