Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

unexpected error?


franco_oz

Recommended Posts

Posted

Hey guys, i just started using oscommerce and using it locally with easyphp to setup my store.

I can use the admin area with no problem but i can't see the catalog. This is what happen when i try localhost/catalog

 

Warning: require(includes/languages/.php) [function.require]: failed to open stream: No such file or directory in C:\Program Files\EasyPHP-5.3.2i\www\catalog\includes\application_top.php on line 288

 

Fatal error: require() [function.require]: Failed opening required 'includes/languages/.php' (include_path='.;C:\php5\pear') in C:\Program Files\EasyPHP-5.3.2i\www\catalog\includes\application_top.php on line 288

 

I spent 2 days looking in the forum but i can't find what is wrong. I have all the files at right place, english is set as the language and i did not modify or added anything. I am new to php and try to understand the code before changing things.

It may be a simple fix but it puzzles me, have i screwed it up badly?

If this problem is fixed elsewhere in the forum, please let me know as i can't find it anywhere.

Thank you

Posted

Try browsing to: http://localhost/catalog?language=en

 

If that doesn't fix it, then in application_top.php, a few lines above where the problem is occurring, temporarily change this:

include(DIR_WS_CLASSES . 'language.php');

to this:

require(DIR_WS_CLASSES . 'language.php');

After making this change, does the error message and/or location change?

 

Also, what are the cookie paths and domains in your include/configure.php file?

Check out Chad's News.

Posted

How interesting. That function shouldn't be getting called.

 

Would you please post the portion of your application_top.php file, from where it says

// set the language

to where it says

require(DIR_WS_LANGUAGES . $language . '.php');

 

Also, what values are in the 'languages' table of your MySQL database?

Check out Chad's News.

Posted

and after the mod on application_top i get:

 

Parse error: syntax error, unexpected '^' in C:\Program Files\EasyPHP-5.3.2i\www\catalog\includes\classes\language.php on line 87

 

as well.

Posted

i put a mark at the line i changed,

Also, what values are in the 'languages' table of your MySQL database? <=== how do i do that?

 

-----------------------------------------------------------------------------------------

// set the language

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');

}

 

require(DIR_WS_CLASSES . 'language.php'); <==== THIS IS THE LINE I MODIFIED AS PER YOUR POST

$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');

---------------------------------------------------------------------

Posted

You can change that line back to what it used to be.

 

Are you familiar with MySQL and how to view your database?

 

Okay, next thing to try. Create a new file in your website's root directory. Call it p.php and copy this line into it:

<?php phpinfo(); ?>

Then go to http://localhost/p.php

 

You should see a page with a bunch of PHP info. Do a search for this string:

HTTP_ACCEPT_LANGUAGE

and post its value here.

Check out Chad's News.

Posted

One more thing. In these two files

/catalog/include/languages/english.php
/catalog/admin/include/languages/english.php

there is a line near the top that looks something like this:

@setlocale(LC_TIME, '...');

Please post both lines here.

Check out Chad's News.

Posted

Try browsing to: http://localhost/catalog?language=en

 

If that doesn't fix it, then in application_top.php, a few lines above where the problem is occurring, temporarily change this:

include(DIR_WS_CLASSES . 'language.php');

to this:

require(DIR_WS_CLASSES . 'language.php');

After making this change, does the error message and/or location change?

 

Also, what are the cookie paths and domains in your include/configure.php file?

 

I was getting the same errors after installing the multiple stores add on. Chad's fix worked for me after quite a bit of frustration. Thanks man!

No outside links in signature allowed. See forum rules

Posted
when i browse http://localhost/catalog?language=en i get this:

 

Parse error: syntax error, unexpected '^' in C:\Program Files\EasyPHP-5.3.2i\www\catalog\includes\classes\language.php on line 87

 

Franco, would you also post your language.php file:

C:\Program Files\EasyPHP-5.3.2i\www\catalog\includes\classes\language.php

Check out Chad's News.

Posted

Value for HTTP_ACCEPT_LANGUAGE

HTTP_ACCEPT_LANGUAGE en-US,en;q=0.8

 

from /catalog/include/languages/english.php

(line19) @setlocale(LC_TIME, 'en_US.ISO_8859-1');

 

from /catalog/admin/include/languages/english.php

(line17) setlocale(LC_TIME, 'en_US.ISO_8859-1');

Posted

Value for HTTP_ACCEPT_LANGUAGE

HTTP_ACCEPT_LANGUAGE en-US,en;q=0.8

 

from /catalog/include/languages/english.php

(line19) @setlocale(LC_TIME, 'en_US.ISO_8859-1');

 

from /catalog/admin/include/languages/english.php

(line17) setlocale(LC_TIME, 'en_US.ISO_8859-1');

 

I don't think these are causing the problem, but they needed to be checked. You should delete the p.php file that you created.

Check out Chad's News.

Posted

Another thing to try. In application_top.php, after this line:

// set the language

insert the following code:

echo '<p>Default language: ';
if defined('DEFAULT_LANGUAGE')
 echo htmlspecialchars(DEFAULT_LANGUAGE);
else
 echo "Default language not defined";
echo '</p>';
echo '<p>language: ' . htmlspecialchars($HTTP_GET_VARS['language']) . '</p>';
exit();

Then direct your browser to http://localhost/catalog?language=en and tell me what you get on the screen.

Check out Chad's News.

Posted

this is what i get:

Parse error: syntax error, unexpected T_STRING, expecting '(' in C:\Program Files\EasyPHP-5.3.2i\www\catalog\includes\application_top.php on line 269

 

 

damn i am lost now...

Posted

This:

if defined('DEFAULT_LANGUAGE')

should be this:

if (defined('DEFAULT_LANGUAGE'))

My bad. We'll get this figured out, don't lose hope.

Check out Chad's News.

Posted

sorry Chad, shall i remove the last change i made?

and from your last post

This:

if defined('DEFAULT_LANGUAGE')

should be this:

if (defined('DEFAULT_LANGUAGE'))

 

refer to catalog/includes/application_top.php?

Posted

Let me clarify. In application_top.php, where I asked you to insert this:

 

echo '<p>Default language: ';
if defined('DEFAULT_LANGUAGE')
 echo htmlspecialchars(DEFAULT_LANGUAGE);
else
 echo "Default language not defined";
echo '</p>';
echo '<p>language: ' . htmlspecialchars($HTTP_GET_VARS['language']) . '</p>';
exit();

I made an error. It should be this:

 

echo '<p>Default language: ';
if (defined('DEFAULT_LANGUAGE'))
 echo htmlspecialchars(DEFAULT_LANGUAGE);
else
 echo "Default language not defined";
echo '</p>';
echo '<p>language: ' . htmlspecialchars($HTTP_GET_VARS['language']) . '</p>';
exit();

Check out Chad's News.

Posted

This is a process. Right now, we're eliminating possibilities.

 

Go ahead and undo the changes to application_top.php -- restore it to its original state.

 

Then browse to this url and tell me what happens: http://localhost/catalog

Check out Chad's News.

Posted

Here's another thing that may be causing it.

 

Go to your osCommerce admin pages. Log in. Select "Localization" on the left side. Under that, select "Languages".

 

Click the "Edit" button for English. You should see the following values in the edit area:

Name:
English

Code
: en

Image:
icon.gif

Directory:
english

Sort Order:
1

Are these the values you see?

 

Also, check the other languages (if any). Do any of them also have a "Code" of "en"?

Check out Chad's News.

Posted

ok restored the code and i get again this:

Parse error: syntax error, unexpected '^' in C:\Program Files\EasyPHP-5.3.2i\www\catalog\includes\classes\language.php on line 87

 

and yes it is all set as it should:

Name: English

Code: en

Image: icon.gif

Directory: english

Sort Order: 1

 

there are no other languages set

Posted

just to clarify, when i installed oscommerce i set it up adding AUD for Australia, created the zones and the tax. After that i removed the original settings defaulting to US and tried it. All worked fine. I also replaced line 16-17 in catalog/includes/application_top.php and admin/includes/application_top.php

 

// set the level of error reporting

error_reporting(E_ALL & ~E_NOTICE);

 

With:

// set the level of error reporting

error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);

 

All this was done well before i had the problem.

Posted

Result of: http://localhost/catalog?language=en

Parse error: syntax error, unexpected '^' in C:\Program Files\EasyPHP-5.3.2i\www\catalog\includes\classes\language.php on line 87

 

======== language.php ========================

 

<?php

/*

$Id: language.php 1739 2007-12-20 00:52:16Z hpdl $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

 

browser language detection logic Copyright phpMyAdmin (select_lang.lib.php3 v1.24 04/19/2002)

Copyright Stephane Garin <[email protected]> (detect_language.php v0.1 04/02/2002)

*/

 

class language {

var $languages, $catalog_languages, $browser_languages, $language;

 

function language($lng = '') {

$this->languages = array('ar' => 'ar([-_][[:alpha:]]{2})?|arabic',

'bg' => 'bg|bulgarian',

'br' => 'pt[-_]br|brazilian portuguese',

'ca' => 'ca|catalan',

'cs' => 'cs|czech',

'da' => 'da|danish',

'de' => 'de([-_][[:alpha:]]{2})?|german',

'el' => 'el|greek',

'en' => 'en([-_][[:alpha:]]{2})?|english',

'es' => 'es([-_][[:alpha:]]{2})?|spanish',

'et' => 'et|estonian',

'fi' => 'fi|finnish',

'fr' => 'fr([-_][[:alpha:]]{2})?|french',

'gl' => 'gl|galician',

'he' => 'he|hebrew',

'hu' => 'hu|hungarian',

'id' => 'id|indonesian',

'it' => 'it|italian',

'ja' => 'ja|japanese',

'ko' => 'ko|korean',

'ka' => 'ka|georgian',

'lt' => 'lt|lithuanian',

'lv' => 'lv|latvian',

'nl' => 'nl([-_][[:alpha:]]{2})?|dutch',

'no' => 'no|norwegian',

'pl' => 'pl|polish',

'pt' => 'pt([-_][[:alpha:]]{2})?|portuguese',

'ro' => 'ro|romanian',

'ru' => 'ru|russian',

'sk' => 'sk|slovak',

'sr' => 'sr|serbian',

'sv' => 'sv|swedish',

'th' => 'th|thai',

'tr' => 'tr|turkish',

'uk' => 'uk|ukrainian',

'tw' => 'zh[-_]tw|chinese traditional',

'zh' => 'zh|chinese simplified');

 

$this->catalog_languages = array();

$languages_query = tep_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order");

while ($languages = tep_db_fetch_array($languages_query)) {

$this->catalog_languages[$languages['code']] = array('id' => $languages['languages_id'],

'name' => $languages['name'],

'image' => $languages['image'],

'directory' => $languages['directory']);

}

 

$this->browser_languages = '';

$this->language = '';

 

$this->set_language($lng);

}

 

function set_language($language) {

if ( (tep_not_null($language)) && (isset($this->catalog_languages[$language])) ) {

$this->language = $this->catalog_languages[$language];

} else {

$this->language = $this->catalog_languages[DEFAULT_LANGUAGE];

}

}

 

function get_browser_language() {

$this->browser_languages = explode(',', getenv('HTTP_ACCEPT_LANGUAGE'));

 

for ($i=0, $n=sizeof($this->browser_languages); $i<$n; $i++) {

reset($this->languages);

while (list($key, $value) = each($this->languages)) {

if (preg_match(‘/^(‘ . $value . ‘)(;q=[0-9]\\.[0-9])?$/i’, $this->browser_languages[$i]) && isset($this->catalog_languages[$key])) {

$this->language = $this->catalog_languages[$key];

break 2;

}

}

}

}

}

?>

Posted

I think I've found the problem. Due to the forum fonts, it's not visible from the post you made, but when I copied and pasted the language.php code, I found a problem on line 87. The single quotes have been replaced with "fancy" quotes.

 

Here is line 87 in your existing code:

 

if (preg_match(‘/^(‘ . $value . ‘)(;q=[0-9]\\.[0-9])?$/i’, $this->browser_languages[$i]) && isset($this->catalog_languages[$key])) {[

 

As you can see, there are 4 single quotes. Three of them are "fancy" left quotes and one is a "fancy" right quote.

 

The correct code should be this:

 

if (preg_match('/^(' . $value . ')(;q=[0-9]\\.[0-9])?$/i', $this->browser_languages[$i]) && isset($this->catalog_languages[$key])) {[

 

Please let me know if this solves your problem.

Check out Chad's News.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...