[PHP] Display a database image from MSSQL database

2005-05-18 Thread Alaor Barroso
Hi... I need to display some images that exists inside one MSSQL
server in a BLOB datatype field, but my code don't work...

My code:

?
$arg = $_GET[codPessoa];
mssql_connect(server, web, web);
$sql = SELECT Foto FROM Foto WHERE CodPessoa=$arg;
$result = mssql_query($sql);
$data = mssql_result($result, 0, Foto);
$data = stripslashes($data);
header(Content-type: image/gif);
echo $data;
exit;
? 

And I access this page sending in the URL the text:
.../showimage.php?codPessoa=xxx.

I receive a strange code like
Fh54757eFg554257eFrgtth547d54e7t8h54j87j85fd54ss7f.. Accessing
this page by IE nothing happens but when a I try to access in Mozilla
Firefox I got an error saying that the image cointain errors and
cannot be displayed... If i try to show inside an img TAG in other
page like img src=patch/to/page / the code display a X error img,
like if the image don't exist, but the code keep returning the strange
code, so I believe that this is the image in a string format and
something makes with the conversion for a real image format don't work
very well.

Sorry my bad english...

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Fwd: [PHP] Display a database image from MSSQL database

2005-05-18 Thread Alaor Barroso
Thankz the atention.

I try to cut out the stripslashes and it also not work, and yes, the
images are valid, i can use it in delphi apps with no errors.

={

2005/5/18, Richard Lynch [EMAIL PROTECTED]:
 On Wed, May 18, 2005 10:28 am, Alaor Barroso said:
  Hi... I need to display some images that exists inside one MSSQL
  server in a BLOB datatype field, but my code don't work...
 
  My code:

 ... contains NO error checking.  That's bad.

  ?
  $arg = $_GET[codPessoa];
  mssql_connect(server, web, web);
  $sql = SELECT Foto FROM Foto WHERE CodPessoa=$arg;
  $result = mssql_query($sql);
  $data = mssql_result($result, 0, Foto);
  $data = stripslashes($data);

 Nooo!

 If you are calling stripslashes() on data coming out of your databsae, you
 have almost for sure really screwed up much earlier in the process, by
 having both Magic Quotes on and calling addslashes() (or
 mysql_real_escape_string) or something similar.

 You would only do stripslashes() here if you've hacked php.ini to use
 Magic Quotes on data coming *OUT* of the database, which is really quite
 rare to do -- You'd want that only on a site where, what?, you were
 shlepping a bunch of stuff out of one database and into another???

  header(Content-type: image/gif);
  echo $data;
  exit;
  ?
 
  And I access this page sending in the URL the text:
  .../showimage.php?codPessoa=xxx.
 
  I receive a strange code like
  Fh54757eFg554257eFrgtth547d54e7t8h54j87j85fd54ss7f.. Accessing
  this page by IE nothing happens but when a I try to access in Mozilla
  Firefox I got an error saying that the image cointain errors and
  cannot be displayed... If i try to show inside an img TAG in other
  page like img src=patch/to/page / the code display a X error img,
  like if the image don't exist, but the code keep returning the strange
  code, so I believe that this is the image in a string format and
  something makes with the conversion for a real image format don't work
  very well.

 Your stripslashes() corrupted the image, assuming it was valid in the
 first place.

 --
 Like Music?
 http://l-i-e.com/artists.htm



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Merry Christmas ;o]

2004-12-24 Thread Alaor Barroso
Merry Christmas and happy new year for all that is
part of php community, god bless us. Peace!





___ 
Yahoo! Acesso Grátis - Instale o discador do Yahoo! agora. 
http://br.acesso.yahoo.com/ - Internet rápida e grátis

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] PHP + MSSQL Problem

2004-12-18 Thread Alaor Barroso
Hello guyz, sorry my bad english, im brazilian and
i'll try to write in english...

I use actually PHP 5.02 with MySQL in my site, but now
i have to access an external server that use MS SQL
Server running at windows 2000 server edition, firtly
i tried to connect and it fails, because i don't have
activately properly MSSQL support in php.ini...

I changed the php.ini and enabled the support for
MSSQL and now i can connect without errors, BUT when
make an query to an table the query return NO MATCHES,
i have sure that the SQL line is correct (i already
used it on(or in? i don't know the difference =P)
other site - in other server - and it works AND i have
sure that the SQL should return data because the WHERE
point to an fiels value that exists... 

It looks like PHP can't communicate with MSSQL but it
connect! Strange...

I need help friends, waiting for replys, hugs. Sorry
my bad english, cya.





___ 
Yahoo! Acesso Grátis - Instale o discador do Yahoo! agora. 
http://br.acesso.yahoo.com/ - Internet rápida e grátis

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php