1

I modified the detectmobilebrowsers.com php script to write 1 or 0 in the url passed in the redirect so I can just script which style sheet I need based on if the viewing browser is mobile or not. It's working great adding ?det=0 for not mobile or ?det=1 if it is a mobile browser. However, in my header file, my IF statement is always returning the not-mobile html regardless of the value of det in the url. I'm sure this is elementary, but I can't get it!

the url format i'm using is www.cypressbotanicals.com/main.php?det=1

Excerpted from the < head > section of header.php:

<?php
$mob = $_GET['$det'];
if($mob==1): ?>
<link rel="stylesheet" href="css/mobile.css" type="text/css" media="screen" /><!--is mobile-->
<?php else: ?>
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" />
<?php endif ?>
<link rel="stylesheet" href="css/scheck.css" type="text/css" media="screen" />
2
  • 3
    Try $_GET['det']; (remove the $ from the array key name) Commented Sep 6, 2018 at 13:05
  • that was, pf course, precisely it! Thanks! Commented Sep 6, 2018 at 13:20

1 Answer 1

1

The issue is that when you're running your $_GET, you're looking for something that's prefixed with a $, which is used for PHP variables, but not this!

$mob = $_GET['$det'];

Will look for https://example.com/index.php?$det=foo

$mob = $_GET['det'];

Will look for https://example.com/index.php?det=foo

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! i knew it had to be something because the second half of the if statement was executing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.