Jump to content

undefined index with language files...help!


NathanS

Recommended Posts

Hi guys,

 

I'm rectifing an old website, and everything works flawlessly bar the languages - its been coded for multiple languages, as such the index page looks like this:

 

   echo "<TABLE class=NewsTicker width=585><TBODY><TR><TD><a href=\"chatroom.php?rhx=2523457370726573736F426172\">EspressoBar</a> - <i>All ages welcome at the EspressoBar - Fun and friendly chat!</i></TD></TR></TBODY></TABLE>";
    layout_text( "{$_index[0]}", "{$_index[1]} {$_index[2]}" );
    layout_text( "{$_index[3]}", "{$_index[4]}<br>{$_index[5]} <a href=\"includes/NPPGWrap.exe\">{$_index[6]}</a> {$_index['7']}" );
    layout_text( "{$_index[8]}", "{$_index[9]}" );
    layout_footer( );
}

 

With $_index[0] etc being the relative text which is defined in the language files, as below:

 

$_index[0] = "Welcome to N2N Chat!";
$_index[1] = "A new network made especially for you! Why? Because we want to make your online experience as enjoyable as possible, N2N Chat is your best msn chat alternative!";
$_index[2] = "Chat now and get acquainted with the possibilities of N2N Chat today!";

 

But the error I'm getting is: Notice: Undefined variable: _index in d:\domains\korix.co.uk\wwwroot\n2nchat\index.php on line 9

 

Over and over again. Any ideas?

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/122527-undefined-index-with-language-fileshelp/
Share on other sites

function layout_text( $header, $text )
{
    echo "<TABLE cellSpacing=0 cellPadding=0 width=600 border=0>\r\n<TBODY>\r\n<TR>\r\n<TD vAlign=top colSpan=2>\r\n<TABLE class=TextBoxFull cellSpacing=0 width=585>\r\n<TBODY>\r\n<TR>\r\n</TR>\r\n<TR>\r\n</TR>\r\n<TR>\r\n<TD>\r\n<B>{$header}</B>\r\n</TD>\r\n</TR>\r\n<TR>\r\n<TD>{$text}<BR>\r\n</TD>\r\n</TR>\r\n</TBODY>\r\n</TABLE>\r\n</TD>\r\n</TR>\r\n</TBODY>\r\n</TABLE>";
}

 

And yes, include the language file!

But the error I'm getting is: Notice: Undefined variable: _index in d:\domains\korix.co.uk\wwwroot\n2nchat\index.php on line 9

 

this might go away if you define the variable before using it:

 

$_index = array();
$_index[0] = "Welcome to N2N Chat!";
$_index[1] = "A new network made especially for you! Why? Because we want to make your online experience as enjoyable as possible, N2N Chat is your best msn chat alternative!";
$_index[2] = "Chat now and get acquainted with the possibilities of N2N Chat today!";

are you including the file that defines $_index before any code that uses $_index? the error 'undefined variable' tells me that you are using the variable before it is defined.

 

ah, just saw your last post. have you tried defining $_index before the include instead of inside the include?

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.