- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
So not only didn't they consider to use PHP Data Objects, they couldn't even be bothered with prefixing their functions with
db_
?Woe be upon the one adding another function called
info
.Admin
My thoughts exactly.
Admin
Maybe it was inside an object called db?
Admin
wait a minute!
do really php returns a list or a bool from a method?
this is the real WTF
Admin
FTFY
Admin
thanks!
Admin
One of these days, when I'll be able to afford all the travel, I'm going to find the author of every newly written tutorial (and those who still maintain the site and they haven't added disclaimers to old tutorials) that uses
mysql_
and/ormysqli_
functions and bludgeon them to death.Yes. And yes, it's stupid. But not that much more stupid than shit other dynamically typed languages do. Which is not en excuse for either of them, I just kinda get annoyed that PHP tends to be the only language that gets called on it.
Admin
Looks like he was paid by the hour :P
Admin
FTFY
Admin
Not only did they not think of using PDO but evidently Remy knows nothing about it as well:
Admin
Remy probably knew it existed, but the point of that paragraph was to bash PHP as per usual. Can't let people forget that it's a fractal of bad design.
Admin
I am not a web developer, but perhaps someone could tell me why you want to access a database with PHP directly?
Admin
As opposed to...?
If your site's in PHP, PHP is your back-end. Why wouldn't you access the database with it?
Admin
But... but... if we don't use Node, Redis, Sidequik, Mongo and SQLite before we even hit MySQL / Postgres / Oracle / MSSQL we won't be webscale!
Filed under: I kid, but tell me it doesn't genuinely feel that way lately
Admin
The Real WTF is using the mysql_* functions at all. Those things have been deprecated for years and anyone using them really ought to be taken out, shot, and then forced to eat a physical print-out of their code
Admin
Yup, that was my initial reaction, too. I know a lot of articles are written a few days or even a few weeks before they're posted to the site, but I didn't realize that Remy sometimes writes his articles 10 years in advance.
Admin
Is "doesn't know PHP all that well" really a negative, though?
Admin
Well, i think that if you insist on bashing PHP, at least bash it for its actual faults, not those that were patched a long time ago.
Cause, you know, it isn't that hard.
Admin
but man! haven't you read that article? fractal of something? it bashes PHP! so it must be TR :wtf:
Admin
http://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/
Admin
Oh wait, I forgot something...
Filed Under: I feel dirty now, please help
Admin
Better start printing the source code... :p
Admin
###How to print computer program using PHP?
Hello freinds. I have a progream that needs to print using PHP to my printer. How wuold I do that? If I type print("something.php") it doesn't print it.
Admin
###Re: How to print computer program using PHP?
Hello sloose, you could try doing it in a separate thread. Sometimes PHP is too slow for printing.
Admin
###RE: Re: How to print computer program using PHP?
Can you give me teh codez?
Right now I have
Admin
Turing fucking damnit, I know you were just joking, but I... I can't, I just can't I have this fear some dumbass will see it and actually use it!
If you ACTUALLY HAVE TO use
mysql
/mysqli
extension because RAISINS:http://php.net/manual/en/mysqli.prepare.php
http://php.net/manual/en/mysqli.prepare.php
#http://php.net/manual/en/mysqli.prepare.php
FOR THE LOVE OF ANYTHING THAT IS HOLY TO YOU, USE FUCKING PREPARE!
Or, you know,
PDO::prepare
, because it's not actually utter shit.AFTER you disable perparation emulation because some idiot thought it would be better to do it in PHP than in the actual fucking RDBMS that knows what the fuck it's doing!
</rant>
Admin
and where do you call
msql_real_not_real_escape_string
?Admin
Nowhere, because you use THE FUCKING PREPARE FUNCTIONS.
While we're talking about PHP, there is one nice thing in PDO that can fuck you over if you're not careful:
http://php.net/manual/en/pdostatement.bindvalue.php
http://php.net/manual/en/pdostatement.bindparam.php
What's the difference? From
bindParam
docs:Sounds reasonable, yes? It's even in the docs!
Well, yes it is, but am I crazy for thinking that, for benefit of the noobies, this stuff should be clearly marked in some fashion? Bold text, highligted block, something?
Because it sure did bite me on the ass when I only started learning. The only reason I remember it to this day is that it took me freaking ages to find the bug. My fault? Likely. But damn it, I'd appreciate that stuff visibly marked.
Admin
I see three links, but four click counters (the stupid bubbles with numbers). Discourse!!!
Admin
###Re: How to print computer program using PHP?
Hi sloose, I think you should be using the jquery. see:
If this does not work please send me your browser version and we may troubleshoot.
bb36e | MSDN Technet Support Expert
Admin
you missed the :trolleybus: on @Jaloopa's post
Admin
Nah, I just wanted to vent a bit. Seemed like a good opportunity.
Admin
Because (for the types of sites I work with), the WebServer would be publically exposed and contact a set of services (likely, but not necessarily ReST) that reside in a more secure environment which would in turn (either directly or not) contact the DB.
Makes for a MUCH better scalability server when you need to create a garden or farm for your front ends.
Admin
Or better, call it something like
bindDeferred
ofbindReference
which makes it obvious what the difference is.Oh wait, this is PHP, naming things right is :doingitwrong:
Admin
Programming today is a race between PHP engineers building to strive bigger and better idiot-proof fractals, and the Discodevs trying to produce bigger and better WTFs. So far, the Discodevs are winning.
Admin
+
discourse_real_bake_post()
Admin
Right? I'm pretty much sure my thought process at the time was:
bindParam
, sounds reasonable... yup, that works! Intuitive name, too! Thanks, Google and PHP docs!Note: I was probably doing something stupid at the time. The most stupid thing I did was assume PHP is smart, though.
Admin
The internet really needs some kind of expiration method. Google seems to give weight to things that have been around a while, which makes sense for certain things, but not for others.
The stack overflows of the world need to do a better job letting people know what is bad or outdated advice besides a comment from someone 5 under the wrong answer with 432 upvotes.
Admin
Why stop there?
Better have that REST service call other REST services. Just in case. In fact, better add another layer or two. Make sure as much pointless, stupid code gets between the user and their data as possible.
Admin
https://what.thedailywtf.com/t/sigh-why-do-i-even-try-a-novlet-on-stackoverflow/51280/
Admin
I could see that coming up in a for loop type thing... You end up inserting the same thing 10,000 times rather than 10,000 different things
Admin
I love how Discourse randomly gave me a linked post notification for this despite you not linking to one of my posts.
Admin
It was probably something like that, yes.
These days I just use
bindValue
99.9% of the time, becausebindParam
behaving the way it does is very rarely actually useful (IMHO) unless it's some kind of stylistic choice (write query and bindings in one block, then handle values, then just call execute, for example).Admin
Actually I did, originally. Because copying from /u/topics gives you the "last post" link, not the "op" link. Because :raisins:
Then I :hanzo: edit'd the link to point to the OP :P
Now, why Discourse still sends notifications within the :hanzo: edit period? Who tf knows...
Admin
PHP has several functions that can return 0 or false, which mean different things, but 0 == false.
Admin
Psh, why would you ever need to differentiate the two?
Admin
I saw a job ad that wanted proficiency in the following four fields:
I'm not sure what they're making, but why the fuck do they need all four of those things?
Admin
They need to write their entire db and system twice for redundancy purposes. Obviously. That's how you make fallback servers, right?
Admin
I'm actually torn on whether I like it in some cases or not.
For example,
strpos
returns0
if substring is found at the beginning of the string,FALSE
if substring is not found. C would return-1
in place ofFALSE
.So... on one hand it's a clear distinction and
if(strpos($string, $substring) === FALSE)
looks nicer thanif(strpos($string, $substring) === -1)
But... mixing booleans and integers...
Admin
Yeah. It makes sense, if you know how it works. But it's so crazily error prone, and not-newb friendly. And PHP has a LOT of newbs