Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> PDO - postgres bytes
hettmix
post
Post #1





Grupa: Zarejestrowani
Postów: 60
Pomógł: 0
Dołączył: 10.03.2012

Ostrzeżenie: (0%)
-----


Witam.

Próbuję pobrać z bazy postgres dane typu bytes (zdjęcie w formacie jpeg):
  1. <?php
  2.  
  3. try{
  4. $db = new PDO('pgsql:host=173.225.xx.xx;dbname=xxxxxx', 'postgres', 'xxxxxxxxxxx');
  5. $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  6. $db->exec("SET CLIENT_ENCODING TO 'UTF8'");
  7. }
  8. catch (PDOException $e)
  9. {
  10. print "Błąd połączenia z bazą!: " . $e->getMessage() . "<br/>";
  11. die();
  12. }
  13.  
  14. $bif_id = trim($_GET['bif_id']);
  15.  
  16.  
  17. if ($_GET['bif_id']) {
  18.  
  19. $sql="SELECT jpeg_zdjecie from zdjecia_p where (bif_id='".$bif_id."')";
  20. $sqh=$db->query($sql);
  21. $sqh->execute(array($_GET['bif_id']));
  22. $data=$sqh->fetchAll(PDO::FETCH_NUM);
  23. $data=$data[0][0]; // print($data) here will just return "Resource id #"
  24. //print $data;
  25. //header('Content-Type: image/jpeg');
  26. $data=fgets($data);
  27. print $data;
  28.  
  29. }
  30.  
  31. ?>

W efekcie otrzymuję tylko fragment danych
[txt]
����JFIF``��C 
[/txt]
Jak to ugryźć ?
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 27.12.2025 - 00:26