Author Topic: common.php undefined variable string  (Read 1859 times)

0 Members and 1 Guest are viewing this topic.

Offline MeteoQc

  • Member
  • *
  • Posts: 31
    • Meteo Rimouski
common.php undefined variable string
« on: June 04, 2014, 12:05:14 PM »
Hello guys,

Recently I encourted an error with my Ajax website that consist of this error (each time I load a page) in /etc/httpd/logs/error_log :

Code: [Select]
[error] [client *.156.194.*] PHP Notice:  Undefined variable: string in /var/www/html/meteo/common.php on line 430, referer: http://www.meteorimouski.ca/index.php
Line 430 of common.php is only this:

Code: [Select]
';
Lines 417 to 438 are :

Code: [Select]
# this function by mchallis prints (language selection flags or language selection text links)
# based on the setting $SITE['useLanguageFlags'] true or false
function print_language_selects_linear() {
 global $SITE;

 $string1 = '';
 $arr = $SITE['installedLanguages'];
 if (is_array($arr)){
    foreach ($arr as $k => $v) {

      if($SITE['useLanguageFlags'] == true) {
           $string .= '<a href="'. $_SERVER['PHP_SELF'] .'?lang='.$k.'" title="'. $v .'">
<img src="'. $SITE['imagesDir'] . 'flag-'. $k .'.gif" alt="'. $v .'" title="'. $v .'" border="0" /></a>
';
      }else{
           $k_print = $k;
           if ($_REQUEST['lang'] == $k) {
              $k_print = "[$k]";
 if (is_array($arr)){
                       [ ligne 417/748 (55%), col. 1/95 (1%), car. 15302/38337 (39%) ]

      if($SITE['useLanguageFlags'] == true) {
           $string .= '<a href="'. $_SERVER['PHP_SELF'] .'?lang='.$k.'" title="'. $v .'">
<img src="'. $SITE['imagesDir'] . 'flag-'. $k .'.gif" alt="'. $v .'" title="'. $v .'" border="0" /></a>
';

If someone have a clue of what is happening there, I will gladly accept some help!

I don't know if it's related, but sometimes my site don't react when I refresh the main page (clientraw.txt don't load) and i'm stuck on the main page. If I click another link in my site it doesn't work. Apache is misconfigurated maybe ? Or PHP ? My website is hosted on a VPS with 8Gb of RAM and 6 cores CPU access, so I don't think the problem is here.

Thanks,

Fred

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9297
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: common.php undefined variable string
« Reply #1 on: June 04, 2014, 12:16:11 PM »
I'm not sure this is the issue, but your Settings.php has
Code: [Select]
$SITE['langavail'] = array('fr',     // select languages to offer here.
// array('en', should be first entry on line above
// other languages with the Canada set can be enabled by installing language packs
//  'af',  // afrikaans
//  'ct', // 'catalan',
//  'dk', // 'danish',
//  'nl', // 'dutch',
//  'fi', // 'finnish',
  'fr', // 'french',
//  'de', // 'german',
//  'el', // 'greek',
//  'it', // 'italian',
//  'no', // 'norwegian',
//  'pl', // 'polish',
// 'pt', // 'portuguese',
//  'es', // 'spanish',
//  'se', // 'swedish',
);
and should list French only once like this
Code: [Select]
$SITE['langavail'] = array('fr',     // select languages to offer here.
// array('en', should be first entry on line above
// other languages with the Canada set can be enabled by installing language packs
//  'af',  // afrikaans
//  'ct', // 'catalan',
//  'dk', // 'danish',
//  'nl', // 'dutch',
//  'fi', // 'finnish',
//  'fr', // 'french',
//  'de', // 'german',
//  'el', // 'greek',
//  'it', // 'italian',
//  'no', // 'norwegian',
//  'pl', // 'polish',
// 'pt', // 'portuguese',
//  'es', // 'spanish',
//  'se', // 'swedish',
);

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline MeteoQc

  • Member
  • *
  • Posts: 31
    • Meteo Rimouski
Re: common.php undefined variable string
« Reply #2 on: June 04, 2014, 12:52:52 PM »
Thank you for your quick reply.

I have done what you said but it doesn't change anything, the error is still there. I will leave it that way anyway.

BUT, I have changed this line:

Code: [Select]
$SITE['allowLanguageSelect'] = true;
To this:

Code: [Select]
$SITE['allowLanguageSelect'] = false;
And the error doesn't comes up anymore!

Fred

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9297
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: common.php undefined variable string
« Reply #3 on: June 04, 2014, 01:05:08 PM »
Since you only wish to offer French on the site, your fix is likely the best one :)

It may be that the trailing comma on
Code: [Select]
$SITE['langavail'] = array('fr',     // select languages to offer here. is causing a null second entry in the array.  Changing it to
Code: [Select]
$SITE['langavail'] = array('fr'      // select languages to offer here. and turning on the language select again may stop the error message.

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline MeteoQc

  • Member
  • *
  • Posts: 31
    • Meteo Rimouski
Re: common.php undefined variable string
« Reply #4 on: June 04, 2014, 01:15:35 PM »
I have deleted the comma and set allowLanguageSelect back to 'true' and the error re-apeared  #-o

I will just leave allowLanguageSelect to 'false' as it resolved my problem.

Have a nice day, and thank you for your help  :-)

Fred

Offline BigOkie

  • Forecaster
  • *****
  • Posts: 1369
  • Tulsa, OK
    • KOKTULSA13
Re: common.php undefined variable string
« Reply #5 on: June 04, 2014, 02:12:29 PM »
I have deleted the comma and set allowLanguageSelect back to 'true' and the error re-apeared  #-o

I will just leave allowLanguageSelect to 'false' as it resolved my problem.

Have a nice day, and thank you for your help  :-)

Fred

FYI, the logged item isn't really an error; it's a notice and changing the way php logs to apache via the php.ini file will eliminate the notice entries.  If you have a way to do that.

Not saying you even want to, but it's an option.  I turned my notice entries off because it wrote too much to the error logs when notices aren't 'technically' errors.
Current setup: Davis Vantage Pro 2 Plus Wireless
Weather radios:
Reecom R-1650
Sangean CL-100
Uniden Home Patrol I