echoing somtin out

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

Post Reply
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

echoing somtin out

Post by shiznatix »

im completly confused as to why this does not work

Code: Select all

</center>
</td>
</tr>
</table>
</form>
<?
$lang->DoL('NEW_USER_CLICK');
?> 
<a href="new_user/new_user.php">
<?
$lang->DoL('HERE');
?>
that does not work. but when i put the $lang->DoL('NEW_USER_CLICK'); after the $lang->DoL('HERE'); then it shows. I know i spelled everything correct and It was working the other day then it all of a sudden stopped working. If there is somthing obvious im missing please tell me but otherwise i have no idea
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Maybe show us the contents of the $lang class
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

Code: Select all

'VIEW_CV_IN' => array
            (
                'est' => '*Choose Which Language To View Your CV In*',
                'eng' => 'Choose Which Language To View Your CV In',
            ),
            'COMMENTS' => array
            (
                'est' => '*Comments*',
                'eng' => 'Comments',
            ),
            'ADD_MESSAGE' => array
            (
                'est' => '*Add Message*',
                'eng' => 'Add Message',
            ),
            'ADD_COMMENT' => array
            (
                'est' => '*Add Comment*',
                'eng' => 'Add Comment',
            ),
            'COMMENT_ADDED' => array
            (
                'est' => '*Comment Added*',
                'eng' => 'Comment Added',
            ),
            'PRINT_IN_LANG' => array
            (
                'est' => '*Choose a language to print the cv\'s in*',
                'eng' => 'Choose a language to print the cv\'s in',
            ),
        );

    function SetLang($lang)
	{
	    if ($lang !== 'eng' && $lang !== 'est')
		{
		    trigger_error('Invalid Language', E_USER_ERROR);
		}
		else
		{
		    $_SESSION['lang'] = $lang;
		}
	}
	
	function DoL($change)
	{
	   if (isset($_SESSION['lang']))
	   {
	       if(isset($this->text[$change][$_SESSION['lang']]))
		   {
		       echo $this->text[$change][$_SESSION['lang']];
		   }
	   }
	   else
	   {
	       trigger_error('No Language Set', E_USER_ERROR);
	   }
	}

    function DoLcV($change)
	{
	   if (isset($_GET['lang_id']))
	   {
           $lang = ($_GET['lang_id'] == '1' ? 'est' : 'eng');

	       if(isset($this->text[$change][$lang]))
		   {
		       echo $this->text[$change][$lang];
		   }
	   }
	   else
	   {
	       trigger_error('No Language Set', E_USER_ERROR);
	   }
	}
}
the array is only part of the array, its a huge array (over 1000 lines) but you get the idea. there is no reason that i can think of for it not to work. whats even stranger is that when i view source it shows correctly but on the page in the browser it dosnt show. i really have no idea. here is a link
http://www.koduleht.net/~andrew/cv/
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

It's early, so excuse me if I'm way off, but...
Might not solve any issues, but it just doesn't look right.

Code: Select all

array
            (
                'est' => '*Add Message*',
                'eng' => 'Add Message'  // <-- the , removed as it's the last 
            )
Another example.

Code: Select all

'PRINT_IN_LANG' => array
            (
                'est' => '*Choose a language to print the cv\'s in*',
                'eng' => 'Choose a language to print the cv\'s in', // here...
            ), // ...and here...
wyred
Forum Commoner
Posts: 86
Joined: Mon Dec 20, 2004 1:59 am
Location: Singapore

Post by wyred »

JAM wrote:It's early, so excuse me if I'm way off, but...
Might not solve any issues, but it just doesn't look right.

Code: Select all

array
            (
                'est' => '*Add Message*',
                'eng' => 'Add Message'  // <-- the , removed as it's the last 
            )
Another example.

Code: Select all

'PRINT_IN_LANG' => array
            (
                'est' => '*Choose a language to print the cv\'s in*',
                'eng' => 'Choose a language to print the cv\'s in', // here...
            ), // ...and here...
Extra commas at the end won't affect the array in any way as far as I know. It works fine.

To the threadstarter, you might want to try echoing your arrays using:

Code: Select all

echo '<pre>';
print_r($this->text); // or any other array
echo '</pre>';
to make sure your arrays are properly set up.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

after some testing and its only happening in firefox. my table kinda breaks up too, but only in firefox. this is the only place in the script where this happens and i use that array for every single text output on the site.
Post Reply