Page 1 of 1

Parsing Syntax Error in Tera-WURFL code

PostPosted: Tue Jan 24, 2012 5:59 pm
by accendi
I successfully installed Tera-WURFL, but when I include the following code from your site, I get a Parsing/Syntax error message.

<?php
require_once '.../Tera-Wurfl/TeraWurfl.php';
$wurflObj = new TeraWurfl();
$wurflObj->getDeviceCapabilitiesFromAgent();
 
// see if this client is on a wireless device
if ($wurflObj->getDeviceCapability("is_wireless_device")) {
header("http://yourwebsite.mobi/");
}
?>

(I haven't redirected to the mobile site address yet.) The error message is:

Parse error: syntax error, unexpected T_IF in /..../header.php on line 7

in which line 7 is:

if ($wurflObj->getDeviceCapability("is_wireless_device")) {

PHP version is 5.2.17

Any help would be greatly appreciated. Thanks.

Re: Parsing Syntax Error in Tera-WURFL code

PostPosted: Tue Jan 24, 2012 10:24 pm
by kamermans
The error message is saying that the parsing error is in header.php. When it says "unexpected T_IF..." it means that there was an error before the "if" statement and so it is unexpected. This usually means you're missing a semicolon or a closing parenthesis or something. Sometimes when you copy a code sample from a website, the quotation marks can be malformed, so you might try checking them. Also, I see the require_once statement says ".../" instead of "../", so perhaps there are some other errors as well.