Prob in Detecting Phon Browser

Started on the old forum in May 2009 · view the original in the archive · old links redirect here

5 replies · 623 views · started 17 years ago · 1 min read

5 participants
anderson Developer · 146 posts #1

Hello, I am using lava wml scripts. Lately I am facing a prob is that at times my script can't detect users mobile browser! Browser field shows empty. It means users browser data cant insert in database. why this happening? Need proper solutions or if anyone has the better browser detecting function plz post here.

Wait...

Anshul Senior · 296 posts #2

anderson wrote: Hello, I am using lava wml scripts. Lately I am facing a prob is that at times my script can't detect users mobile browser! Browser field shows empty. It means users browser data cant insert in database. why this happening? Need proper solutions or if anyone has the better browser detecting function plz post here.

function realbro($_mob_browser)
{
if(preg_match('/(google|bot)/i',strtolower($_mob_browser)))
{
$position = strpos(strtolower($_mob_browser),"bot");
$_mob_browser = substr($_mob_browser, $position-30, $position+2);
$_browser = explode (" ", $_mob_browser);
$_browser  = array_reverse($_browser);
}
else if (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']))
{
$_mob_browser = $_SERVER['HTTP_X_OPERAMINI_PHONE_UA'];
$_position=strpos(strtolower($_mob_browser),"nokia");
if($_position)$_mob_browser = substr($_mob_browser, $_position,25);
$_browser = explode ("/", $_mob_browser);
}
else
{
$_position=strpos(strtolower($_mob_browser),"nokia");
if($_position)$_mob_browser = substr($_mob_browser, $_position,25);
$_browser = explode ("/", $_mob_browser);
}
return $_browser[0];
}

realbro($_SERVER['HTTP_USER_AGENT'])

anderson Developer · 146 posts #3

Error

Your function shows syntax error, unexpected T_MUL_EQUAL @ anshul

Wait...

magicdesign Newbie · 1 posts #4

have you tryed handsetdetection.com? it might save you some time.

kei_ki7 Senior · 431 posts #6

anderson wrote: Hello, I am using lava wml scripts. Lately I am facing a prob is that at times my script can't detect users mobile browser! Browser field shows empty. It means users browser data cant insert in database. why this happening? Need proper solutions or if anyone has the better browser detecting function plz post here.

put this in core.php

function get_mob_browser($_mob_browser)
{

if(preg_match('/(google|bot)/i',strtolower($_mob_browser)))
{
$position = strpos(strtolower($_mob_browser),"bot");
$_mob_browser = substr($_mob_browser, $position-30, $position+2);
$_browser = explode (" ", $_mob_browser);
$_browser = array_reverse($_browser); 
}
else if (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA'])) 
{
$_mob_browser = $_SERVER['HTTP_X_OPERAMINI_PHONE_UA'];
$_position=strpos(strtolower($_mob_browser),"nokia");
if($_position)$_mob_browser = substr($_mob_browser, $_position,25);
$_browser = explode ("/", $_mob_browser);
}
else 
{
$_position=strpos(strtolower($_mob_browser),"nokia");
if($_position)$_mob_browser = substr($_mob_browser, $_position,25);
$_browser = explode ("/", $_mob_browser);
}

return $_browser[0];
}

put this where you want to update the browser, some of script put this in login.php or index.php

			$brws = explode(" ",$_SERVER[HTTP_USER_AGENT] );
			$ubr = get_mob_browser($brws[0]);
			$uip = getip();
			$res = mysql_query("UPDATE ibwf_users SET browserm='".$ubr."', ipadd='".$uip."' WHERE id='".getuid_sid($sid)."'");

browserm varchar(200) NOT NULL default '',

Did I help you? You can help me too Your donations will help me finance my studies.

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close