logs archiveIRC Archive / Freenode / #php / 2006 / June / 7 / 13
richardlynch
TheNinthCut: Yes -- If you are not sending the image out to the browser, and you are saving it into a file, then you do not want/need the header("Content-type:") at all.
TheNinthCut: You may want to use FireFox and that plug-in that reveals the HTTP headers and examine some HTML and some IMG tags to see how it all fits together, for when you WILL need the header("Content-type:") down the road someday.
AfroTurf
TheNinthCut: if making or resizing images on the fly, thats when you'd want to use Content-type
TheNinthCut
AfroTurf, I'm resizing an image but just saving it, and not outputting it to the browser.
AfroTurf
TheNinthCut: if your not outputting then no you don't need it
TheNinthCut: an example is <img src="resize.php?image=something.jpg&width=640&height=480" />
zircu
i would avoid resizing on the fly
AfroTurf
ya it's slow
zircu
not very friendly with 60 hits per second
AfroTurf
very slow
richardlynch
For those of us who get a lot less than 60 hits per second it can be handy, especially if the some of the content embedded into the image changes frequently...
         

zircu
true, or you have a built in cache system
AfroTurf
but if you have alot of pics on 1 page, it would be slow as well
richardlynch
Just depends on the needs / traffic.
If you have a lot of pics on one page, it's gonna be slow. Period. :-)
AfroTurf
ya but resizing even slower :)
cythrawll
another thing you can do is use a separate web server with thttpd or the like to serve static content
helps things quite a bit
so apache can concentrate on the dynamic bits
(I don't know if im even on the same page or not I just got back and read the last 8 lines or so)
TheNinthCut
Hmm....
ChrisC36
when I do a query, doing if (mysql_query(bla..) then shoudl I do an }else{die;}?
i would like the script to stop if the query errors
borland
do this
TheNinthCut
Would it error? I thought it would just return NULL.
borland
$result = mysql_query($sql) or die($sql);
AfroTurf
ChrisC36: yes but wouldn't you like to know why there was an error in your query?
ChrisC36
its a query that updates a field
borland
and then do something with $result, like check how many rows it has using mysql_num_rows()
^^
AfroTurf
ChrisC36: i like to do something like this if(!($result=mysql_query($sql))) { die(mysql_errno().": ".mysql_error()); }
ChrisC36
this is the query: UPDATE mailing SET start = now() where mailing_id = $mailing_id
nice
richardlynch
Really really, what you ought to do is print a nice generic error for the users to see, and log the mysql_error for yourself... IMHO
AfroTurf
start='NOW()'
ChrisC36
so AfroTurf this executes the query, and only stops the script if theres and error, and prints the error to the screen?
cythrawll
richardlynch, that would be good.
AfroTurf
ChrisC36: yes
         

ChrisC36
very good
AfroTurf
ChrisC36: but i would set my own error handler though
ChrisC36
you mean to produce a more user friendly error message?
AfroTurf
ChrisC36: yes and/or log and/or email
ChrisC36
yes good, however for now this script is only for my use
AfroTurf
ok
richardlynch
That's fine then
cythrawll
you should never output sql errors to the users, because they could intentionally cause errors, and read the error statements to gain information about your database schema
ChrisC36
true
richardlynch
Never is kinda strong... If the "user" is you, or the owner/admin, and you're reasonably confident of the authentication, and the user's ability to comprehend error messages... Still...
cythrawll
better to be in the habit imho
richardlynch
That as an awful lot of "if"s there. :-)
AfroTurf
don't use @ to surpress errors though
richardlynch
Yeah, I still have the habit of @ in front of pg_fetch_row() cuz it used to do E_NOTICE after the last row.
AfroTurf
the only time i've ever found @ usefull is for sockets
ah never used that type of db
Rick
eh, I use it for file operations too
usually
to mask any stupid warnings
:P
richardlynch
Oh yeah. file_exists warns you when the file doesn't exist? Hunh?!
AfroTurf
lol
cythrawll
stupid warning
Rick
richardlynch: eh? no?
AfroTurf
if(!file_exists($file)) { echo 'no no no'; }
richardlynch
Yes -- for that case, you kinda have to use it. Assuming it still does that.
Rick
hmm
i've never known file_exists to throw a warning
richardlynch
These could be habits picked up from PHP 3.0RC2 days, mind you... :-)
Rick
ah
well, I usually don't use file_exists when i'm writing shell scripts
just @fopen :P
cythrawll
RC specific even...
richardlynch
Old Dog.
AfroTurf
there was probably lots of @ used back in those days
richardlynch
Not really -- And you wanted to avoid it then, as much as possible, as well.
cythrawll
dinosaurs used @
AfroTurf
(Action) is not that old, so i don't know
cythrawll
and then a T-Rex ate Andi
richardlynch
But did he enjoy it? :-)
cythrawll
yeah
it made Zeef giggle
richardlynch
That was a double-entendre... Think about it.
cythrawll
s/f/v
richardlynch
s/ee/e'e/
cythrawll
orly?
i thot about it
pervert
richardlynch
You said it, not me :-)
cythrawll
you thought it
are you sure it's e'e?
richardlynch
He gave up on getting people to spell it right, much less pronounce it right, but yeah. Ze'ev is the closest English there is for it.
Zuh - ev is kinda how it sounds.
Fooker
Hey all. I'm new to php and may just be missing something here completely, but is there a way with with the post get method to put a default value to the variable if no value is retreived?
richardlynch
Fooker: You could do like this: $value = isset($_POST['value']) ? $_POST['value'] : 'default value';
Then you have to make sure that the data looks reasonable to avoid Bad Guys.
cythrawll
oh
because i noticed in the blog it says zeev
s/the/his
but good to know
richardlynch
Yeah, I think he even answers to the pronunciation "Zeav" now. :-)
Fooker
richardlynch: Eh, internal network with no internet connection. Access to the boss is protected by a cook with a 20" pizza knife. Its safe :)
box*
cythrawll
no such thing
unless there is no internet connection
richardlynch
He said no internet connection, so I'm guessing he meant it... :-)
Fooker
No internet connection within a few hundred feet of the room even :)
But I will keep in mind the security for future reference
richardlynch
And a cook with a 20" pizza knife is pretty good -- Though unless it's a 24-hour joint... :-)
cythrawll
oh , thats what i get for scanning over things i guess
Fooker
Trust me, she wouldn't let her own kids into the kitchen, nevermind anyone wanting to do bad things to her computer
cythrawll
heh, I read once in a security manual that advised to have guard dogs in the server room
i wonder what genius thought that one up
Fooker
I find they urinate on equipment
cythrawll
yeah,
and shed
richardlynch
Nah, you need a moat and then a fence with the dogs, and then another fence.
cythrawll
and hair is bad for computers components
Fooker
Although if arranged properly, I suppose that could be collected and used to refill your cooling system...
Might not smell the greatest at 70 degrees though
cythrawll
maybe i should train komodo dragons, they don't shed hair
richardlynch
And a temperamental chef with a 20" pizza knife.
I suppose tempramental goes without saying, eh?
cythrawll
well sharpened pizza knife
Fooker
Sharpened goes without saying for a pizza knife
cythrawll
it would help if he had a menacing italian accent too
richardlynch
A real chef will have it sharp, and have a sharpener in their pocket.
Fooker
And tempermental goes without saying for a cook :)
I could never fit the sharpener in the apron pouch - the four knives took up too much space.
w00t! It worked :)
Thanks guys
richardlynch
Painter-style pants with the sharpener down the side pocket. Still black/white check, of course.
Do they make chef pants in painter style? Seems like a no-brainer to me...
Hook a ladel on that loop on the left side. :-)
cythrawll
invention!
lets market it
richardlynch
You market it, and I'll settle for 5%. :-) Marketing things is WAY too hard.
Fooker
No no no, you let a large company market it for a 5% cut
Thats what I did
True, I never actually got anywhere with it
(half the equipment arrived before we found out someone else had patented it... :()
ChrisC36
the way to stop a script in general is die; correct?
cythrawll
yes
exit(); same thing
ChrisC36
t
Fooker
I know its not the right place, but the people in #bash hate me... is it @1 or $1 for the first argument on the command line?
richardlynch
$1 -- $@ is all of them.
I think.
Fooker
Thanks
litage
what exactly does the session.cache_expire setting in php.ini do? i don't quite undersand the explanation on php.net
zircu
i ponder why
litage
zircu: ?
zircu
litage: not for you
« prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 next »