Looks like correct code should read
<?php
defined('_JEXEC') OR die("Restricted access");
$lang =& JFactory::getLanguage();
$lng=substr($lang->getName(),0,2);
$db =& JFactory::getDBO();
require_once './plugins/mobile/terawurfl/TeraWurfl.php';
$width = 0;
try
{
$wurflObj = new TeraWurfl();
if($wurflObj->db->connected)
{
$wurflObj->getDeviceCapabilitiesFromAgent();
$width = $wurflObj->getDeviceCapability("resolution_width");
}
}
catch(Exception $e){}
//...?>
PS. And TeraWurflConfig.php should contain correct settings (db credentials, etc.).