473,387 Members | 1,463 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 1517

"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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.