Problem display MySQL blob properly #2

------=_NextPart_000_0005_01C260A4.6AB9A6D0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi=20

I am using the following PERL (dbi/dbd-mysql) code snippet to display a =
blob image to browser. Problem is that it is displaying as low =
resolution  I guess I am missing something. BTW it displays perfectly =
well using graphical interface MySQLFront.  Any tips or hints would be =
appreciated.

Howard

begin snip------------------------------------>
($dbh->{LongReadLen} =3D 50000);
($sth =3D $dbh->prepare( "SELECT * FROM testblob where number =3D =
'$number'")) or die $DBI::errstr;
$rv=3D($sth->execute )or die $DBI::errstr;
while (($number,$picture,$fieldblob) =3D $sth->fetchrow){
print "Content-type: image/jpeg \n\n";
print "$fieldblob";
<-------------------------------------------end snip=20

------=_NextPart_000_0005_01C260A4.6AB9A6D0--

0
howard
9/20/2002 7:51:20 PM
perl.dbi.users 11100 articles. 1 followers. Follow

1 Replies
10101 Views

Similar Articles

[PageSpeed] 2
Get it on Google Play
Get it on Apple App Store

On Fri, 20 Sep 2002 12:51:20 -0700 Howard Fuchs <howard@uztwo.com> wrote:

> I am using the following PERL (dbi/dbd-mysql) code snippet to display a
> blob image to browser. Problem is that it is displaying as low
> resolution  I guess I am missing something. BTW it displays perfectly
> well using graphical interface MySQLFront.  Any tips or hints would be
> appreciated.
> 
> begin snip------------------------------------>
> ($dbh->{LongReadLen} = 50000);
> ($sth = $dbh->prepare( "SELECT * FROM testblob where number =
> '$number'")) or die $DBI::errstr;
> $rv=($sth->execute )or die $DBI::errstr;
> while (($number,$picture,$fieldblob) = $sth->fetchrow){
> print "Content-type: image/jpeg \n\n";
> print "$fieldblob";
> <-------------------------------------------end snip 

I'm slightly surprised the image is displaying at all.  It is binary and
you don't appear to have switched STDOUT to binmode.  After you do, you
will have to expand the "\n"s to "\xd\xa" yourself.  The '"'s in the last
print are not needed.

On the DBI side, you may be able to save a lot of database effort by using
placeholders.  You are also not getting any error checking from fetchrow()
unless you '$dbh -> {RaiseError} = 1'.

I hope you have '-w' in the '#!' line and are using 'use strict;'.

-- 
Mac :})
** I normally forward private questions to the appropriate mail list. **
Ask Smarter: http://www.tuxedo.org/~esr/faqs/smart-questions.html
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.

0
mchase
9/21/2002 2:45:21 PM
Reply:

Similar Artilces:

Problem display MySQL blob properly
------=_NextPart_000_0008_01C260C0.0D976C50 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi=20 I am using the following PERL (dbi/dbd-mysql) code snippet to display a = blob image (stored in a MySQL table) to browser. Problem is that it is = displaying as low resolution I guess I am missing something. BTW it = displays perfectly well using graphical interface MySQLFront. Any tips = or hints would be appreciated. Howard begin snip------------------------------------> ($dbh->{LongReadLen} =3D 50000); ($sth =3D ...

2.18.1 -> 2.22.2 mysql problem(?)
I'm running Bugzilla 2.22.2 on Gentoo GNU/Linux. I upgraded from 2.18.1 using an ebuild "yesterday" (a few hours ago.) Gentoo wanted to upgrade my MySQL from 3.x to 4.0.24. I let it do the upgrade. It went nicely at first. checksetup.pl returned no errors (it just told me about optional modules, which I ignored, and it did "stuff" to upgrade the database.) Sanity Check returned no errors. Then when mysql went down (predictably) as a result of the cron job that handles backups, mysql didn't come back up. I'm still fighting with this. It seems ...

Problem Displaying MySQL Crystal Report in ASP.NET 2.0
I am trying to display a Crystal Report developed using MySQL database and ASP.NET 2.0 (VS.NET 2005), and for some reason when I pass the database login information to the report it does not accept them (still shows a db login screen). Here is the code:1 Imports CrystalDecisions.CrystalReports.Engine 2 Imports CrystalDecisions.Shared 3 Imports System.IO 4 Imports MySql.Data.MySqlClient 5 6 ' Class Name etc here ... 7 8 Dim conn As New MySqlConnection 9 10 conn = New MySqlConnection("Server=servername; Database=dbname; User ID=dbuser; Passw...

Install problem updating 2.20.2 to 3.0.2 (DBD::mysql::db )
Hi All, I perform the update of the mysql from v. 4.0.15 to 5.0.45 I permorm the update of the modules required from checksetup log through = bugzilla 3.0.2. But when I try to enter in buzilla, I receive the following error. When I downgrade to ver 2.20.2 all came back ok. How I can solve the problem ? Thank you ERROR: DBD::mysql::db selectrow_hashref failed: Unknown column = 'profiles.disable_mail' in 'field list' [for Statement " SELECT profiles.userid AS = id,profiles.login_name,profiles.realname,profiles.mybugslink AS = showmybugslink...

TB 2 beta 2 Display Problem
Updated one machine from 1.5.0.9 with nary a hitch. On a second machine, tried to do same thing, but some of subjects in all of the mail folders repeat and overlay each other. Tried a zillion things with no success: changed font sizes, compacted folders, reindexed both manually and automatically, started in safe mode, re-d/l'ed and reloaded, etc. I can go back to 1.5.0.9 with no problem, so it's hard to believe the files are corrupted. Sounds as if it may be a css type of problem. Any thoughts on things to look at or try? Thanks! CTinFL Cal Tinson wrote: > Update...

imanage 2.0.2 user template problem
hi all I am using imanager 2.0.2 edir 8.7.3 and NW 6.0 sp3. I have a user template which I made in console 1 that creates a user that has object FS rights RWECMF on the home dir and also a volume quota, however when I use imanager to create the account the home dir get the above rights and also Access Control and no quota is assigned. Any suggestions on fixing these problems, out security policy does not allow users to have access control on their home dir. Thank you Alberto Oria FIU Alberto, It appears that in the past few days you have not received a response to your pos...

problem in install DBI in solaris 2.8 #2
Hi: Now, i have problems for install DBD-Oracle-1.12, can help me? Here is the LOG: # perl Makefile.PL Using DBI 1.20 installed in /usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris/auto/DBI Configuring DBD::Oracle ... >>> Remember to actually *READ* the README file! Especially if you have any problems. Using Oracle in /home/users/oracle/app/product/8.0.6 8.0.6.0.1 ORACLE Common RDBMS Libraries and Utilities 8.0.6.0.0 ORACLE PL/SQL Libraries 8.0.6.0.1 ORACLE Common Precomp Libraries 8.0.6.0.0 PL/SQL 8.0....

Problem with DBI #2
------_=_NextPart_001_01C6AF1B.8E2016D8 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi, I'm seeing the following warning message from DBIx::ContextualFetch intermittently. Use of uninitialized value in null operation at /usr/local/lib/perl5/site_perl/5.8.6/DBIx/ContextualFetch.pm line 51.=20 What does it mean? Sorry, I am not in a position to provide a simple test case as I still can't reproduce the problem at will. palisetk@desa0587.nyc:~$ perl -MDBI -e 'DBI->installed_versions;' Perl : 5....

MySQL DBI Problem.
I have a Perl cron job that reads emails off a pop server once a minute and stores them in a MySQL database on a remote machine. I logged onto the MySQL server today and performed a select * from messages where received > 20030322000000; Zero records were returned. I did some more investigating and discovered that no records had been inserted in 4 days. I performed a "flush tables" (Someone suggested it, I don't know what it does) command and the records were still missing, but suddenly the Perl cron job on the other machine, without any changes, was po...

DBI problem #2
ok, now i am getting an error that my locales are incorrectly set, deart gd this is too much ...

display problem #2
in my db I have  colum otherfile, subject,link <ItemTemplate>     <a  href='\Cedars\File\UploadFile\<%# DataBinder.Eval(Container.DataItem, "otherFile") %>' target="_blank">      <%# DataBinder.Eval(Container.DataItem, "subject") %>     </a>     <a href='<%# DataBinder.Eval(Container.DataItem, "link1") %>' target="_blank"><%# DataBinder.Eval(Container.DataItem, "l...

DBI and mySQL problems
Hi, First, sorry for the wrap on the lines below, and my apologies if this message has been seen already- I appear to be having problems sending to nntp.perl.org (I didn't realise you had to be subscribed to beginners@perl.org to send). I am trying to insert some values into a mySQL database, all of the scalars below have a value(none are undefined). I keep getting errors similar to the one below and despite being instructed to read the mySQL manual, I cannot find anything that relates to the problem I'm experiencing. Is the problem with my Perl (likely), or mySQL? C...

mysql through dbi problem
Howdy, I'm having some serious trouble. I'm running a query and getting the data, but having problems using that data in the next query. Thus: #first query $sth = $dbh->prepare ( "select distinct hmac, hport, hsid from netdata_history" ); $sth->execute( ); $sth->bind_columns ( undef, \$hmac, \$hport, \$hsid ); while ( ( $hmac, $hport, $hsid ) = $sth->fetchrow_array ) { push @hsid, $hsid; push @hport, $hport; push @hmac, $hmac; } $sth->finish(); #now cycle through result set in next query ...

MySQL DBI problem
--Apple-Mail-2--747237304 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed I am trying to read email off a mail server using perl, parse it, and then store the fields in a MySQL database. I managed to write the first two parts in a couple of days, but now I've spent two weeks trying to get the fields into a the "Messages" database. I have got several fields to go in and then I ran the same script the next day with no changes and it wasn't working any longer. I have run into about every problem imaginable and I c...

Web resources about - Problem display MySQL blob properly #2 - perl.dbi.users

Statement of Disaffiliation from the GUU regarding failure to properly address Misogynistic behaviour ...
Glasgow Uni Coalition of Resistance hat eine Notiz mit dem Titel Statement of Disaffiliation from the GUU regarding failure to properly address ...


How to use a Ketchup Cup Properly - YouTube
Ever carry over 8 cups full of ketchup back to your table, try to dunk more than one fry at a time, and think to yourself, "This doesn't seem ...

University reforms haven't been explained properly, says Sydney Uni's Michael Spence
... of the proposal to uncap university fees has taken an apparent swipe at the government's sales job saying the case for change hasn't been properly ...

Canada crash train brakes not set properly
A lone engineer failed to set brakes properly on a train that derailed and exploded in a small Canadian town, killing at least 15 people, the ...

Toddler's life may have been saved if car seat was properly fitted
A two-year-old girl who died when the car her mother was driving collided with a street sweeper may have survived if her car seat was properly ...

Queensland Health probes: 50,000 x-rays not properly checked
An investigation is underway after revelations almost 50,000 x-rays taken at public hospitals on the Gold Coast have not been properly checked. ...

Negative gearing works if it’s done properly
The government is out of step on the tax concession, but a Labor plan could position the party as a champion of more affordable housing.

Fracking's effect on water not properly monitored, report finds
A new report commissioned by Environment Canada says there's little information about the effects of shale gas development on the environment. ...

'We want to know how to love them properly,' veteran's spouse says
A day after confronting the Veterans Affairs minister over lack of support for veterans’ caregivers, the wife of a former Canadian Forces sergeant ...

Resources last updated: 12/17/2015 10:17:20 PM