Problem with php coding...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Torleif
Forum Newbie
Posts: 14
Joined: Thu Apr 14, 2011 10:12 pm

Problem with php coding...

Post by Torleif »

I've the following code, there is an error but I can't quite figure it out. If someone see something wrong with the code, please shed some light. Thanks...

Fatal error: Call to undefined function bind_textdomain_codeset() in /Users/Jesper/Documents/workspace/neptunediving.com/inc/config.php on line 47

Code: Select all

<?php
session_start();

// Error config
ini_set('display_errors',1);
error_reporting(E_ALL);

// DB config
$dbhost = 'localhost';
$dbuser = 'neptune';
$dbpass = 'neptunediving';
$dbname = 'neptune';

include $ROOT . '/inc/functions.php';

// Define available and default locales
$available_locales = array('en_GB', 'ru_RU', 'sv_SE');
$default_locale = 'en_GB';

// Check if locale is set in session
if (! isset($_SESSION['locale'])){
	// Check users locale
	$user_locale = strtolower(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2));
	
	//Check if users locale is available
	if (in_array($user_locale, $available_locales)){
		$_SESSION['locale'] = $user_locale;
	} else {
		$_SESSION['locale'] = $default_locale;
	}
}

// Check if user want to change the locale
if (isset($_GET['locale']) && $_GET['locale'] != 'null'){
	$requested_locale = $_GET['locale'];
	
	// Check if users choice is available
	if (in_array($requested_locale, $available_locales)){
		$_SESSION['locale'] = $requested_locale;
	}
}

// Set chosen locale for whole site
putenv("LANGUAGE=" . $_SESSION['locale']);
putenv("LANG=" . $_SESSION['locale']);
setlocale(LC_ALL, $_SESSION['locale']);
bind_textdomain_codeset("messages", 'utf8');
bindtextdomain('messages', $ROOT . '/locale');
textdomain('messages');

date_default_timezone_set('Asia/Manila');
?>
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: Problem with php coding...

Post by fugix »

To include GNU gettext support in your PHP build you must add the option --with-gettext[=DIR] where DIR is the gettext install directory, defaults to /usr/local.
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: Problem with php coding...

Post by fugix »

you need to add the above so that PHP recognizes that function...right now it doesn't recognize it
Torleif
Forum Newbie
Posts: 14
Joined: Thu Apr 14, 2011 10:12 pm

Re: Problem with php coding...

Post by Torleif »

Yes but i have tried and i do not get it to work. Could you please xplain to me one time in detail how to make this and from where?
I have tried a few ways already via the terminal but i have to got this to work yet. Please help me because i have to idea how to get this up and running now.
Torleif
Forum Newbie
Posts: 14
Joined: Thu Apr 14, 2011 10:12 pm

Re: Problem with php coding...

Post by Torleif »

I have another thread here where i have tried to explain my problem. Maybe this could help you understand better what my problem is,
viewtopic.php?f=1&t=129295
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: Problem with php coding...

Post by fugix »

you add --with-gettext[=DIR] into your php.ini file...remember DIR will be the gettext install directory...the default is /usr/local
Torleif
Forum Newbie
Posts: 14
Joined: Thu Apr 14, 2011 10:12 pm

Re: Problem with php coding...

Post by Torleif »

Ok, but as you can see in my other thread here i have tried this but i don't get it to work. I understand what you are saying but i don't know how and where exactly to install gettext to get this working? At the moment my /usr/local have only this;

bin
mysql
mysql-5.1.50
share

My gettext are located here what i can see at the moment, /opt/local/var/macports/distfiles/gettext/gettext-0.17
Sow hat do i need to do from here then to get this work and placed in the right folder?
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: Problem with php coding...

Post by fugix »

below --with-gettext=DIR add

extension=gettext.so
Torleif
Forum Newbie
Posts: 14
Joined: Thu Apr 14, 2011 10:12 pm

Re: Problem with php coding...

Post by Torleif »

sorry but i have no idea what you mean with this mate?

Like i siad i am not an expert with this so i need some more help...
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: Problem with php coding...

Post by fugix »

in your php.ini file add

extension=gettext.so

as well
Torleif
Forum Newbie
Posts: 14
Joined: Thu Apr 14, 2011 10:12 pm

Re: Problem with php coding...

Post by Torleif »

ok, will try this out one time. Thank you for your help with this.
Torleif
Forum Newbie
Posts: 14
Joined: Thu Apr 14, 2011 10:12 pm

Re: Problem with php coding...

Post by Torleif »

I have now put gettext.so here /usr/lib/php/extensions/no-debug-non-zts-20090626/gettext.so

I have also tried to add extension=gettext.so in the php.ini file. Somebody told me that ;extension=php_gettext.dll is for windows so i should take this away and exchange it with extension=gettext.so and without the rem sign. I have tried to restart my server and i have checked my script file i did like this;

I created a php script like this,
<?php
phpinfo();

But i still have the same problem. So what would the next step be to trying solving this problem?
Torleif
Forum Newbie
Posts: 14
Joined: Thu Apr 14, 2011 10:12 pm

Re: Problem with php coding...

Post by Torleif »

I have added gettext-0.18.11 now to directory /use/local/

I have added gettext.se to /usr/lib/php/extensions/no-debug-non-zts-20090626/

I have changed the php.ini file to extension=gettext.so instead of ;extension=php_gettext.dll since this i for Windows, i have a Mac!

Still nothing works so please let me know what i can do here! Or if i have done something wrong that i need to change?
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: Problem with php coding...

Post by fugix »

I will look into it further and let you know
Torleif
Forum Newbie
Posts: 14
Joined: Thu Apr 14, 2011 10:12 pm

Re: Problem with php coding...

Post by Torleif »

Thank you very much for both your time and help with this.
Post Reply