Re: [Phplib-users] Classes, MySQL, Images & phplib
Brought to you by:
nhruby,
richardarcher
From: nathan r. h. <na...@ds...> - 2001-12-31 18:22:32
|
On Mon, 31 Dec 2001, Mike Gifford wrote: > Hi Nathan, > > 1st - Damn your a good resource.. > Thanks :) > OK.. My present code looks like this: > > require('config.php3'); > class Image { > var $db; > function Image($ID='$GLOBALS[ID]') { No quotes in the above, it's not working cause $ID is being set to the string "$GLOBALS[ID]" and not the actual value of the global $ID (as a side note, this happen becasue you're using single quotes which casue literal strings, double quotes would have meant that the string would have been scanned for variable substituion and it would have been ok, but you would have paid a small performance penalty for that substitution. This is where knowing everything about your varibles comes in handy.) > $this->db = new DB_Sql; > $sql="SELECT photo FROM WLPphoto WHERE profileID='$ID'"; > $this->db->query($sql); > while ($this->db->next_record()) { > Header("Content-type: image/jpeg"); > print $this->db->Record['photo']; > } > } > } > > and produces only this: > <html><body></body></html> > > I just want to clarify though.. in the example you gave ($this->db = > new nameOfdbClass;), if I was trying to add this to phpSlash 6.2 > nameOfdbClass; would be DB_Sql (or would it be slashDB? > if all youre tables are in the same databse as the phpslash stuff, then slashDB, else you'll need to make a new subclass of DB_Sql. > Both seem to produce the same result for me.. I even tried commenting > out the header line (Header("Content-type: image/jpeg");) to see if that > would just echo the raw jpg data.. It didn't.. So something's goofing > up... > Make sure you're not outputing anything before that header() call. I bet there's an error creeping in (probably from using the wrong db class) that's casuing it. For something liek what you're doing I like to add a construct like this to the top of my code: if ($debug && $HTTP_GET_VARS[breakme]) { echo "I'm outputing something to break the headers.<br>\n"; echo "This will allow me to see what exactly I'm sending.<br>\n"; echo "Including errors :)<br>\n"; } Also, check to make sure (for debug pruposes) error_reporting is set to E_ALL. And FWIW, I'd do a $this->db->nf() and make sure the returned valus is 1 and if it isn't sending a "not availible" jpeg to the browser before entering the while() loop. This ensures that if the script freaks out and can't find a image in the databse, something is returned to the user indicating so :) -n -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- nathan hruby / digital statement na...@ds... http://www.dstatement.com/ Public GPG key can be found at: http://www.dstatement.com/nathan-gpg-key.txt ED54 9A5E 132D BD01 9103 EEF3 E1B9 4738 EC90 801B -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- |