Richard Korts
asked on
php problem?
I have a very simple php program (attached). It is linked to from another place.
In Firefox, I get the attached jpg.
In Chrome I get a blank screen.
I ran the php syntax through http://phpcodechecker.com/. No issues.
What's wrong?
clear_sess.php
php_issue.jpg
In Firefox, I get the attached jpg.
In Chrome I get a blank screen.
I ran the php syntax through http://phpcodechecker.com/. No issues.
What's wrong?
clear_sess.php
php_issue.jpg
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ray,
I found the issue; the variable $loc was not set in the non iphone, etc. devices case. Therefore, the header("Location: " . $loc) could not work. Makes PERFECT sense that Chrome displays a blank page.
Because of your questions I put in a bunch of echos, they led me to the solution.
Richard
I found the issue; the variable $loc was not set in the non iphone, etc. devices case. Therefore, the header("Location: " . $loc) could not work. Makes PERFECT sense that Chrome displays a blank page.
Because of your questions I put in a bunch of echos, they led me to the solution.
Richard
Great!
A "standard" design pattern in almost any programming language is to assign the default variable values before any conditional code block that can change the variable values. So something like this would be wise...
A "standard" design pattern in almost any programming language is to assign the default variable values before any conditional code block that can change the variable values. So something like this would be wise...
// SET DEFAULT VALUE TO REDIRECT TO THE HOME PAGE
$loc = '/';
// TEST USER AGENT FOR "PHONE" INDICATORS, CHOOSE REDIRECT PATH
$useragent = !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : NULL;
if ( preg_match('@(iPad|iPod|iPhone|Android|BlackBerry|SymbianOS|SCH-M\d+|Opera Mini|Windows CE|Nokia|SonyEricsson|webOS|PalmOS)@', $useragent) ) {
$loc = "phone.php";
} else {
$loc = "form.php";
}
// GOTO THE APPROPRIATE SCRIPT LOCATION
header("Location: " . $loc);
ASKER
That's EXACTLY what I did.
I often do that but not consistently.
R
I often do that but not consistently.
R
Open in new window