[thelist] javascript variable in php

Jack Timmons jorachim at gmail.com
Wed May 27 10:37:38 CDT 2009


On Wed, May 27, 2009 at 10:35 AM, Jack Timmons <jorachim at gmail.com> wrote:
> On Wed, May 27, 2009 at 10:28 AM, Bob Meetin <bobm at dottedi.biz> wrote:
>> For the purposes of CSS I can use the IE browser IF statements to manage
>> the page.  But say that I have a php script that contains a db query and
>> I want to adjust the query according to the browser.
>>
>> <?php
>> $query = "select * from $table";
>>
>> <!--[if IE6]>
>>  <link rel='stylesheet' type='text/css' href='ie6_styles.css' title='stylesheet'> <!-- this is no brainer -->
>>  <?php $query = "select * from $table where IE6 = 1;" ?> <!-- passing this along is the part that requires brain cells -->
>> <![endif]-->
>
> Well, if you're doing this at page load, you should be able to look at
> $_SERVER['HTTP_USER_AGENT'] to identify the browser, if you really
> want.

And, because I'm anal about security and relying on false info,
remember that the info set in $_SERVER['HTTP_USER_AGENT'] is provided
by the user. Sanitize the data properly, and have something built in
for if that data is absent.

I know you probably do all that, but if I don't warn someone about it
after giving that sort of advice, I get an itch in the back of my
skull that drives me crazy.

-- 
-Jack Timmons
http://www.trotlc.com
Twitter: @codeacula



More information about the thelist mailing list