472,984 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,984 software developers and data experts.

HTTP_BROWSER_AGENT on pocketpc

Hello,

I am having a problem with a simple script that checks and tells the user
what browser they are using.

First of all, the browser string for Internet Exploxer contains the text
msie and the browser string for a Pocket PC version of internet explorer
contain msie AND ppc

The problem is that when browsing my test page using pocket pc the script
still returns Interent Explorer. My script is below, can anyone tell me
how to make it determine correctly when accessing via pocket pc? IT works
ok usign using all the other browsers.

Thanks,

td.

http://www.pocketpcheaven.blogspot.com/
<?
$agent = getenv("HTTP_USER_AGENT");

// check to see if running ie
if (preg_match("/MSIE/i", "$agent")) {
$result = "You are using Microsoft Internet Explorer.";
}
//check to see if running Firefox
else if (preg_match("/Firefox/i", "$agent")) {
$result = "You are using Mozilla Firefox.";
}
// check to see if running opera
else if (preg_match("/Opera/i", "$agent")) {
$result = "You are using Opera.";
}
// check to see if running pocket pc browser
else if ((preg_match("/PPC/i", "$agent")) && (preg_match("/MSIE/i",
"$agent"))) {
$result = "You are using Pocket PC Internet Explorer.";
}
// if anything else just display the browser string
else {
$result = "You are using $agent";
}
?>
<HTML>
<HEAD>
<TITLE>Browser Match Results</TITLE>
</HEAD>
<BODY>
<? echo "<P>$result</P>"; ?>
</BODY>
</HTML>

Jul 17 '05 #1
4 1506

"toedipper" <se******************@hotmail.com> wrote in message
news:36*************@individual.net...
Hello,
Hi.
The problem is that when browsing my test page using pocket pc the script
still returns Interent Explorer. My script is below, can anyone tell me
how to make it determine correctly when accessing via pocket pc? IT works
ok usign using all the other browsers.


The problem is because $agent contains MSIE, the first IF statement citeria
is being met. You are ELSE IF'ing the rest of the way down the script.
Because the first IF statement was met, it won't run anymore IF's. Therefore
I recommend you remove the ELSE's and just run independant IF's.

Ta,
G.
Jul 17 '05 #2
Cheers.

I see what you mean but the browser string for IE also contains the word
Mozilla and that doesn't trip up.

td.
"G-man" <te*****@silentreply.co.uk> wrote in message
news:Ym*****************@text.news.blueyonder.co.u k...

"toedipper" <se******************@hotmail.com> wrote in message
news:36*************@individual.net...
Hello,


Hi.
The problem is that when browsing my test page using pocket pc the script
still returns Interent Explorer. My script is below, can anyone tell me
how to make it determine correctly when accessing via pocket pc? IT
works ok usign using all the other browsers.


The problem is because $agent contains MSIE, the first IF statement
citeria is being met. You are ELSE IF'ing the rest of the way down the
script. Because the first IF statement was met, it won't run anymore IF's.
Therefore I recommend you remove the ELSE's and just run independant IF's.

Ta,
G.

Jul 17 '05 #3
toedipper wrote:
I see what you mean but the browser string for IE also contains the
word Mozilla and that doesn't trip up.


That's because you aren't matching for "Mozilla". What G-man means, is that
you should check for powerpc before IE or make the check for IE less
general:

// check to see if running ie
if (preg_match("/MSIE/i", "$agent") && !preg_match("/PPC/i", "$agent")) {
$result = "You are using Microsoft Internet Explorer.";
}
JW

Jul 17 '05 #4
Janwillem Borleffs wrote:
// check to see if running ie
if (preg_match("/MSIE/i", "$agent") && !preg_match("/PPC/i",
"$agent")) { $result = "You are using Microsoft Internet
Explorer."; }


Coming to think of it, this will also match Opera in MSIE spoofing mode...

The following might work out better (emphasis on "might", because browser
detection based upon the user agent string is always error prone):

if (preg_match("/MSIE/i", $agent) &&
!preg_match("/PPC/i", $agent) &&
!preg_match("/Opera/i", $agent)) {
$result = "You are using Microsoft Internet Explorer.";
}
JW

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: smaggi | last post by:
I have a VB.NET pocketpc application that I need to port to the desktop. What is the best way to do this? Does anyone know where there is a list of steps or checklist? Thanks --...
1
by: Lau | last post by:
I need to synchronize data between a PocketPC application (C#) and a FileMaker database every time the PocketPC is in it’s cradle. FileMaker has a ODBC-plugin, but SQL.CE unly allow me to...
2
by: Pawan Aggarwal | last post by:
I'm having trouble with calling an exported function in a native DLL compiled with eMbedded Visual C++ in C# application in PocketPC 2002 OS. Problem Description follows: I have one exported...
0
by: DL | last post by:
I have an existing application I'm porting to the Windows PC and PocketPC platforms. The UI will be designed from scratch using Visual Studio .NET tools and C#, but key pieces are written in C++. ...
1
by: Keith Smith | last post by:
What is the process for creating setup files for a PocketPC app? (I already know how to create the PocketPC app.)
6
by: db | last post by:
I need to write some basic code that will let me send messages to/from a PocketPC. In the past, when I was using VB6, I did this using the Winsock control and setting one machine as the client and...
2
by: John R. Dougherty | last post by:
I am looking for recommendations on the best installation packages everyone likes right now. I have a PocketPC application for which I want to build a install solution. I have tried many trial...
13
by: Aaron Smith | last post by:
I have a question... Will 3rd party ODBC drivers work on PocketPC? We have drivers to connect to a proprietary database and I was wondering if they would work on a handheld PDA running Windows CE...
0
by: tirumalab | last post by:
HI there, I was trying to call a C# smartdevice dll from VC++ pocket PC console application both were developed using VS.NET 2005. i've registered the dll with the registry and created the...
2
by: ketty_ng81 | last post by:
No matter how many dial up networking entries I have, the RASWrapper.RasEnumEntries(null , null , entryNames, ref cb, out entries); always returns the right number of elelments in entryNames but...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.