Author Topic: PHP "Undefined constant" error - How to correct?  (Read 170 times)

0 Members and 1 Guest are viewing this topic.

Offline K6GKM

  • CamWX.com
  • Senior Member
  • **
  • Posts: 81
    • CamWX
PHP "Undefined constant" error - How to correct?
« on: January 04, 2022, 03:26:47 PM »
Hello Everyone,

Doing a little website maintenance today, and I checked my php error_log file for the first time in a long time.  I have a script throwing a series of errors out every time it's executed, and I was hoping the brains in this forum could help me correct it.  Here's the error:

Code: [Select]
[04-Jan-2022 12:15:01 America/Los_Angeles] PHP Warning:  Use of undefined constant imagesDir - assumed 'imagesDir' (this will throw an Error in a future version of PHP) in ***REDACTED***/wxaqirss.php on line 356
[04-Jan-2022 12:15:01 America/Los_Angeles] PHP Warning:  Use of undefined constant imagesDir - assumed 'imagesDir' (this will throw an Error in a future version of PHP) in ***REDACTED***/wxaqirss.php on line 436
[04-Jan-2022 12:15:01 America/Los_Angeles] PHP Warning:  Use of undefined constant imagesDir - assumed 'imagesDir' (this will throw an Error in a future version of PHP) in ***REDACTED***/wxaqirss.php on line 437
[04-Jan-2022 12:15:01 America/Los_Angeles] PHP Warning:  Use of undefined constant imagesDir - assumed 'imagesDir' (this will throw an Error in a future version of PHP) in ***REDACTED***/wxaqirss.php on line 438
[04-Jan-2022 12:15:01 America/Los_Angeles] PHP Warning:  Use of undefined constant imagesDir - assumed 'imagesDir' (this will throw an Error in a future version of PHP) in ***REDACTED***/wxaqirss.php on line 439
[04-Jan-2022 12:15:01 America/Los_Angeles] PHP Warning:  Use of undefined constant imagesDir - assumed 'imagesDir' (this will throw an Error in a future version of PHP) in ***REDACTED***/wxaqirss.php on line 440
[04-Jan-2022 12:15:01 America/Los_Angeles] PHP Warning:  Use of undefined constant imagesDir - assumed 'imagesDir' (this will throw an Error in a future version of PHP) in ***REDACTED***/wxaqirss.php on line 441
[04-Jan-2022 12:15:01 America/Los_Angeles] PHP Warning:  Use of undefined constant imagesDir - assumed 'imagesDir' (this will throw an Error in a future version of PHP) in ***REDACTED***/wxaqirss.php on line 450
[04-Jan-2022 12:15:01 America/Los_Angeles] PHP Warning:  Use of undefined constant imagesDir - assumed 'imagesDir' (this will throw an Error in a future version of PHP) in ***REDACTED***/wxaqirss.php on line 451
[04-Jan-2022 12:15:01 America/Los_Angeles] PHP Warning:  Use of undefined constant imagesDir - assumed 'imagesDir' (this will throw an Error in a future version of PHP) in ***REDACTED***/wxaqirss.php on line 452
[04-Jan-2022 12:15:01 America/Los_Angeles] PHP Warning:  Use of undefined constant imagesDir - assumed 'imagesDir' (this will throw an Error in a future version of PHP) in ***REDACTED***/wxaqirss.php on line 453
[04-Jan-2022 12:15:01 America/Los_Angeles] PHP Warning:  Use of undefined constant imagesDir - assumed 'imagesDir' (this will throw an Error in a future version of PHP) in ***REDACTED***/wxaqirss.php on line 454
[04-Jan-2022 12:15:01 America/Los_Angeles] PHP Warning:  Use of undefined constant imagesDir - assumed 'imagesDir' (this will throw an Error in a future version of PHP) in ***REDACTED***/wxaqirss.php on line 455
[04-Jan-2022 12:15:01 America/Los_Angeles] PHP Warning:  Use of undefined constant imagesDir - assumed 'imagesDir' (this will throw an Error in a future version of PHP) in ***REDACTED***/wxaqirss.php on line 464
[04-Jan-2022 12:15:01 America/Los_Angeles] PHP Warning:  Use of undefined constant imagesDir - assumed 'imagesDir' (this will throw an Error in a future version of PHP) in ***REDACTED***/wxaqirss.php on line 465
[04-Jan-2022 12:15:01 America/Los_Angeles] PHP Warning:  Use of undefined constant imagesDir - assumed 'imagesDir' (this will throw an Error in a future version of PHP) in ***REDACTED***/wxaqirss.php on line 466
[04-Jan-2022 12:15:01 America/Los_Angeles] PHP Warning:  Use of undefined constant imagesDir - assumed 'imagesDir' (this will throw an Error in a future version of PHP) in ***REDACTED***/wxaqirss.php on line 467
[04-Jan-2022 12:15:01 America/Los_Angeles] PHP Warning:  Use of undefined constant imagesDir - assumed 'imagesDir' (this will throw an Error in a future version of PHP) in ***REDACTED***/wxaqirss.php on line 468
[04-Jan-2022 12:15:01 America/Los_Angeles] PHP Warning:  Use of undefined constant imagesDir - assumed 'imagesDir' (this will throw an Error in a future version of PHP) in ***REDACTED***/wxaqirss.php on line 469

I've loaded fresh copies of the wxaqirss.php package obtained from the legacy scripts page on Mr. Ken True's website, but I just can't seem to make this pesky error go away.  Line 45 sets $imagesDir to a directory of your choice, but the comments say it may or may not be required.  I've tried uncommenting that line, but I still get the error.  The script in question (located at CamWX.com/wxaqirss.php) is attached here (in txt format).  Could anyone offer any insight?

Many Thanks!
« Last Edit: January 04, 2022, 03:38:12 PM by K6GKM »
Grant Miles - Camarillo, CA, USA
Owner/Admin - CamWX.com
SKYWARN Spotter
Davis Vantage Vue, WD, GRLevel3

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8617
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: PHP "Undefined constant" error - How to correct?
« Reply #1 on: January 04, 2022, 03:32:56 PM »
Ahh... the code has
Code: [Select]
// Images Directory (may not be needed, remove the // if needed)
// $imagesDir = "./ajax-images";
but, the comment is not quite right.. it is needed.  So change it to
Code: [Select]
// Images Directory
 $imagesDir = "./ajax-images";
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline K6GKM

  • CamWX.com
  • Senior Member
  • **
  • Posts: 81
    • CamWX
Re: PHP "Undefined constant" error - How to correct?
« Reply #2 on: January 04, 2022, 03:37:42 PM »
Hi Ken,

Thanks so much for the lightning quick reply.  I've tried uncommenting that line, but the problem still persists.   :-k 
Grant Miles - Camarillo, CA, USA
Owner/Admin - CamWX.com
SKYWARN Spotter
Davis Vantage Vue, WD, GRLevel3

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8617
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: PHP "Undefined constant" error - How to correct?
« Reply #3 on: January 04, 2022, 03:46:11 PM »
If you're still getting errata, try changing all the
Code: [Select]
<?php print ${imagesDir}?> to
Code: [Select]
<?php print $imagesDir?>
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline K6GKM

  • CamWX.com
  • Senior Member
  • **
  • Posts: 81
    • CamWX
Re: PHP "Undefined constant" error - How to correct?
« Reply #4 on: January 04, 2022, 06:33:32 PM »
Thank you, Ken.  After making the changes to the print statements, the errors cleared up.    8-)

Thanks again, and take care.
Grant Miles - Camarillo, CA, USA
Owner/Admin - CamWX.com
SKYWARN Spotter
Davis Vantage Vue, WD, GRLevel3

 

anything