I got stupid. The money was too good.

Jayne ,'Objects In Space'


Buffistechnology 3: "Press Some Buttons, See What Happens."

Got a question about technology? Ask it here. Discussion of hardware, software, TiVos, multi-region DVDs, Windows, Macs, LINUX, hand-helds, iPods, anything tech related. Better than any helpdesk!


Jon B. - Jan 12, 2007 1:28:10 pm PST #192 of 25496
A turkey in every toilet -- only in America!

Here's a hopefully simple question for a PHP/MySQL programmer:

I have a PHP page and I want to give it a date as a parameter. The page will then pull off of the database, all records with a matching date. The database field is called Playdate and the parameter is just date. I'd like the URL to look like

blahblahblah.php?date=20070112

So I thought I should be able to do something like

WHERE date_format(Playdate, '%Y%m%d') = $date"

But that doesn't pull any records.

Suggestions?


Tom Scola - Jan 12, 2007 1:30:23 pm PST #193 of 25496
Remember that the frontier of the Rebellion is everywhere. And even the smallest act of insurrection pushes our lines forward.

I don't know the answer to your question, but your code as written will make you vulnerable to an SQL injection attack.


Jon B. - Jan 12, 2007 1:33:09 pm PST #194 of 25496
A turkey in every toilet -- only in America!

Please elaborate....


Tom Scola - Jan 12, 2007 1:36:43 pm PST #195 of 25496
Remember that the frontier of the Rebellion is everywhere. And even the smallest act of insurrection pushes our lines forward.

blahblahblah.php?date=foo';DROP%20TABLE%20XXX


Jon B. - Jan 12, 2007 1:38:31 pm PST #196 of 25496
A turkey in every toilet -- only in America!

Does it help that the page uses read-only access and that there's nothing in the database that I care if people see?


Tom Scola - Jan 12, 2007 1:45:12 pm PST #197 of 25496
Remember that the frontier of the Rebellion is everywhere. And even the smallest act of insurrection pushes our lines forward.

Does it help that the page uses read-only access and that there's nothing in the database that I care if people see?

Yeah, it helps. But avoiding that sort of thing is a good habit to get into.


Jon B. - Jan 12, 2007 3:55:05 pm PST #198 of 25496
A turkey in every toilet -- only in America!

While riding home, I think I figured out a simple way to avoid injection attacks: simply validate that the $date variable is exactly 8 numeric digits.

That should protect me, yes?


Tom Scola - Jan 12, 2007 3:56:47 pm PST #199 of 25496
Remember that the frontier of the Rebellion is everywhere. And even the smallest act of insurrection pushes our lines forward.

That should protect me, yes?

Yes.


Jon B. - Jan 12, 2007 4:12:36 pm PST #200 of 25496
A turkey in every toilet -- only in America!

Thanks.

Annnnndddd... I think I figured out the answer to my original question. I had ORDER BY before the WHERE. By flipping them, I'm finally getting some data! Whee!


DCJensen - Jan 13, 2007 7:59:44 am PST #201 of 25496
All is well that ends in pizza.

interesting development:

Cisco may have lost rights to iPhone trademark last year and tried to extend the trademark with the patent office by slapping a sticker on an existing product.