Forum Moderators: coopster

Message Too Old, No Replies

Unexpected T Constant Encapsed String

         

JonNewbie

11:52 am on Sep 27, 2007 (gmt 0)

10+ Year Member



I came across the following error message when trying to access the homepage of online site : parse error : syntax error, unexpected T_Constant_Encapsed_String on line 288.

The affected section of my PHP script, from line 287 onwards is as follows :

// currency
if (!tep_session_is_registered('currency') ¦¦ isset($HTTP_GET_VARS['currency']) ¦¦ ( (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') && (LANGUAGE_CURRENCY!= $currency) ) ) {
if (!tep_session_is_registered('currency')) tep_session_register('currency');

if (isset($HTTP_GET_VARS['currency'])) {
if (!$currency = tep_currency_exists($HTTP_GET_VARS['currency'])) $currency = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true')? LANGUAGE_CURRENCY : DEFAULT_CURRENCY;
} else {
$currency = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true')? LANGUAGE_CURRENCY : DEFAULT_CURRENCY;
}
}

I have checked through and made many changes to the script, but have not been successful to correct this error. I would greatly appreciate if someone can help me by pointing out the changes I need to make. Thank you in advance.

Best regards,
Jon Newbie

jatar_k

11:58 am on Sep 27, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld JonNewbie,

assuming this line is 288
if (!tep_session_is_registered('currency') ¦¦ isset($HTTP_GET_VARS['currency']) ¦¦ ( (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') && (LANGUAGE_CURRENCY!= $currency) ) ) {

then your actual error probably resides above/before that

look for a missing ; or unmatched quotes before line 288, something is causing the error to appear on that line but it originates before

side note:
HTTP_GET_VARS is deprecated from version 4.1.0 onward, you should use $_GET
[php.net...]

PHP_Chimp

12:07 pm on Sep 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could also save your self some use of keys by using $_GET instead of $HTTP_GET_VARS
Have a look at Predefined variables [uk.php.net]

JonNewbie

12:51 pm on Sep 27, 2007 (gmt 0)

10+ Year Member



Hi All,

Thanks so much for yor replies. The original portion of scripts just before line 288 are as follows :

// set the language -----line 265 ----
if (!tep_session_is_registered('language') ¦¦ isset($HTTP_GET_VARS['language'])) {
if (!tep_session_is_registered('language')) {
tep_session_register('language');
tep_session_register('languages_id');
}

include('classes/language.php');
$lng = new language();

if (isset($HTTP_GET_VARS['language']) && tep_not_null($HTTP_GET_VARS['language'])) {
$lng->set_language($HTTP_GET_VARS['language']);
} else {
$lng->get_browser_language();
}

$language = $lng->language['directory'];
$languages_id = $lng->language['id'];
}

// include the language translations
require(DIR_WS_LANGUAGES . $language . '.php'); ** line 286 ***

Before the current error msg, I was receiving the following error message for the last line 286 :
Warning: main(/includes/languages/english.php) [function.main]: failed to open stream: No such file or directory on line 286.

Therefore I had it changed to :
require('includes/$languages/'.php');

which got rid of the error message , but may have caused the "unexpected t constant encapsed string" on line 288.

If my correction of the require statement on line 286 is causing a new problem on line 288, can you please advise me the correct way to solve for line 286?

My folder directory for this section is public_html/includes/languages , and in the languages folder, there are 3 other folders (english,espanol, german) and 1 file (english.php).

It is highly possible that my correction for the require statement on line 286 may be logically wrong as in reality, there is actually no "$languages" folder.

The above is the historical information just before I received the "unexpected t constant encapsed string" error message. I hope you all can help me on this matter. Thanks in advance.

Best rgds,
Jon Newbie

jatar_k

3:25 pm on Sep 27, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you are exactly right

require('includes/$languages/'.php');

should be something like

require('includes/languages/' . $language . '.php');

I am not sure if the path is completely right but you can adjust it as long as you understand how it works, if not just ask :)

JonNewbie

4:08 pm on Sep 27, 2007 (gmt 0)

10+ Year Member



Hi Jatar,

I have used the script that you advised, and it works!
I cannot say how much I am indebted to you for your help & expertise.

For the past 24 hours, I have been focussing on working out a solution around line 288, when all the time, it was formatted in proper syntax. By this time, I was almost about to give up if not for Webmaster World forum.

Thanks to you, I can move on to trouble-shoot the remainder of the program to bring up my website.

Thank you once again for your kind generousity.
And best wishes on whatever work you're doing.

Yahooooo!

Best regards,
Jon Newbie

jatar_k

7:46 pm on Sep 27, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



hehe, glad that fixed it

come back anytime :)