wdallman Posted December 11, 2009 Share Posted December 11, 2009 I'm getting the following error with this script: Notice: Use of undefined constant php - assumed 'php' I can't figure out what constant I have here that's undefined. Any suggestions? <ul class="sidemenu"> <?php $page = $_SERVER['SCRIPT_NAME']; ?> <?php if (stristr($page, 'index.php')) { ?> <li><a href="auto.php" class="top" class="selected">Auto</a></li> <li><a href="motorcycle.php">Motorcycle</a></li> <li><a href="homeowners.php">Homeowners</a></li> <li><a href="farm.php">Farm</a></li> <li><a href="crop.php">Crop</a></li> <li><a href="commercial.php">Business</a></li> <li><a href="life.php">Life</a></li> <?php } else if (stristr($page, 'motorcycle.php')) { ?> <li><a href="auto.php" class="top">Auto</a></li> <li><a href="motorcycle.php" class="selected">Motorcycle</a></li> <li><a href="homeowners.php">Homeowners</a></li> <li><a href="farm.php">Farm</a></li> <li><a href="crop.php">Crop</a></li> <li><a href="commercial.php">Business</a></li> <li><a href="life.php">Life</a></li> <?php } else if (stristr($page, 'homeowners.php')) { ?> <li><a href="auto.php" class="top">Auto</a></li> <li><a href="motorcycle.php">Motorcycle</a></li> <li><a href="homeowners.php" class="selected">Homeowners</a></li> <li><a href="farm.php">Farm</a></li> <li><a href="crop.php">Crop</a></li> <li><a href="commercial.php">Business</a></li> <li><a href="life.php">Life</a></li> <?php } else if (stristr($page, 'farm.php')) { ?> <li><a href="auto.php" class="top">Auto</a></li> <li><a href="motorcycle.php">Motorcycle</a></li> <li><a href="homeowners.php">Homeowners</a></li> <li><a href="farm.php" class="selected">Farm</a></li> <li><a href="crop.php">Crop</a></li> <li><a href="commercial.php">Business</a></li> <li><a href="life.php">Life</a></li> <?php } else if (stristr($page, 'crop.php')) { ?> <li><a href="auto.php" class="top">Auto</a></li> <li><a href="motorcycle.php">Motorcycle</a></li> <li><a href="homeowners.php">Homeowners</a></li> <li><a href="farm.php">Farm</a></li> <li><a href="crop.php" class="selected">Crop</a></li> <li><a href="commercial.php">Business</a></li> <li><a href="life.php">Life</a></li> <?php } else if (stristr($page, 'commercial.php')) { ?> <li><a href="auto.php" class="top">Auto</a></li> <li><a href="motorcycle.php">Motorcycle</a></li> <li><a href="homeowners.php">Homeowners</a></li> <li><a href="farm.php">Farm</a></li> <li><a href="crop.php">Crop</a></li> <li><a href="commercial.php" class="selected">Business</a></li> <li><a href="life.php">Life</a></li> <?php } else if (stristr($page, 'life.php')) { ?> <li><a href="auto.php" class="top">Auto</a></li> <li><a href="motorcycle.php">Motorcycle</a></li> <li><a href="homeowners.php">Homeowners</a></li> <li><a href="farm.php">Farm</a></li> <li><a href="crop.php">Crop</a></li> <li><a href="commercial.php">Business</a></li> <li><a href="life.php" class="selected">Life</a></li> <?php } else { php?> <li><a href="auto.php" class="top">Auto</a></li> <li><a href="motorcycle.php">Motorcycle</a></li> <li><a href="homeowners.php">Homeowners</a></li> <li><a href="farm.php">Farm</a></li> <li><a href="crop.php">Crop</a></li> <li><a href="commercial.php">Business</a></li> <li><a href="life.php">Life</a></li> <?php } ?> </ul> Quote Link to comment https://forums.phpfreaks.com/topic/184783-undefined-constant-error-in-wampserver/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 11, 2009 Share Posted December 11, 2009 I'll guess the line the error mentioned was the following one - else { php?> There is an extra php on that line that is out of place where php thinks you are trying to use a defined constant named 'php'. Quote Link to comment https://forums.phpfreaks.com/topic/184783-undefined-constant-error-in-wampserver/#findComment-975486 Share on other sites More sharing options...
wdallman Posted December 11, 2009 Author Share Posted December 11, 2009 That took care of half the problem! That sure sticks out better on this site than it does with my text editor (using ConTEXT). I was getting the same error on 2 different lines. Now I'm not getting the error if I click on a page that isn't used in the code, but if I click on a page on the sidemenu, I still get that error. Quote Link to comment https://forums.phpfreaks.com/topic/184783-undefined-constant-error-in-wampserver/#findComment-975494 Share on other sites More sharing options...
premiso Posted December 11, 2009 Share Posted December 11, 2009 Search the sidemenu for the same mistake. You can probably do a ctrl+f for php?> and find it. Either that or post the code where the error is happening around and we will help you. Without the code you will not get much more help. Quote Link to comment https://forums.phpfreaks.com/topic/184783-undefined-constant-error-in-wampserver/#findComment-975496 Share on other sites More sharing options...
wdallman Posted December 11, 2009 Author Share Posted December 11, 2009 I'll post the entire includes() file here. Do you want me to post all of the code from every pertinent file (4 includes files and a little more), or the pagesource code from the browser? I don't think that would be helpful, but let me know. Ctrl F didn't bring up any more php?> problems. This is the sidemenu part I was talking about, notice ul class="sidemenu" Basically, when the code runs all the way to the "else" part, it works fine. But, when $page is one of the sidemenu pages, there's an issue with an undefined constant. I hope I'm making some sense there. As I learn more I might be able to explain more clearly. <td id="sidebar" valign="top"> <h3>Free Quote</h3> <ul class="sidemenu"> <?php $page = $_SERVER['SCRIPT_NAME']; ?> <?php if (stristr($page, 'index.php')) { ?> <li><a href="auto.php" class="top" class="selected">Auto</a></li> <li><a href="motorcycle.php">Motorcycle</a></li> <li><a href="homeowners.php">Homeowners</a></li> <li><a href="farm.php">Farm</a></li> <li><a href="crop.php">Crop</a></li> <li><a href="commercial.php">Business</a></li> <li><a href="life.php">Life</a></li> <?php } else if (stristr($page, 'motorcycle.php')) { ?> <li><a href="auto.php" class="top">Auto</a></li> <li><a href="motorcycle.php" class="selected">Motorcycle</a></li> <li><a href="homeowners.php">Homeowners</a></li> <li><a href="farm.php">Farm</a></li> <li><a href="crop.php">Crop</a></li> <li><a href="commercial.php">Business</a></li> <li><a href="life.php">Life</a></li> <?php } else if (stristr($page, 'homeowners.php')) { ?> <li><a href="auto.php" class="top">Auto</a></li> <li><a href="motorcycle.php">Motorcycle</a></li> <li><a href="homeowners.php" class="selected">Homeowners</a></li> <li><a href="farm.php">Farm</a></li> <li><a href="crop.php">Crop</a></li> <li><a href="commercial.php">Business</a></li> <li><a href="life.php">Life</a></li> <?php } else if (stristr($page, 'farm.php')) { ?> <li><a href="auto.php" class="top">Auto</a></li> <li><a href="motorcycle.php">Motorcycle</a></li> <li><a href="homeowners.php">Homeowners</a></li> <li><a href="farm.php" class="selected">Farm</a></li> <li><a href="crop.php">Crop</a></li> <li><a href="commercial.php">Business</a></li> <li><a href="life.php">Life</a></li> <?php } else if (stristr($page, 'crop.php')) { ?> <li><a href="auto.php" class="top">Auto</a></li> <li><a href="motorcycle.php">Motorcycle</a></li> <li><a href="homeowners.php">Homeowners</a></li> <li><a href="farm.php">Farm</a></li> <li><a href="crop.php" class="selected">Crop</a></li> <li><a href="commercial.php">Business</a></li> <li><a href="life.php">Life</a></li> <?php } else if (stristr($page, 'commercial.php')) { ?> <li><a href="auto.php" class="top">Auto</a></li> <li><a href="motorcycle.php">Motorcycle</a></li> <li><a href="homeowners.php">Homeowners</a></li> <li><a href="farm.php">Farm</a></li> <li><a href="crop.php">Crop</a></li> <li><a href="commercial.php" class="selected">Business</a></li> <li><a href="life.php">Life</a></li> <?php } else if (stristr($page, 'life.php')) { ?> <li><a href="auto.php" class="top">Auto</a></li> <li><a href="motorcycle.php">Motorcycle</a></li> <li><a href="homeowners.php">Homeowners</a></li> <li><a href="farm.php">Farm</a></li> <li><a href="crop.php">Crop</a></li> <li><a href="commercial.php">Business</a></li> <li><a href="life.php" class="selected">Life</a></li> <?php } else { ?> <li><a href="auto.php" class="top">Auto</a></li> <li><a href="motorcycle.php">Motorcycle</a></li> <li><a href="homeowners.php">Homeowners</a></li> <li><a href="farm.php">Farm</a></li> <li><a href="crop.php">Crop</a></li> <li><a href="commercial.php">Business</a></li> <li><a href="life.php">Life</a></li> <?php } ?> </ul> <img src="images/sign.jpg" width="137" height="98" alt="Dallman Insurance Sign" border="0" /> </td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/184783-undefined-constant-error-in-wampserver/#findComment-975514 Share on other sites More sharing options...
cags Posted December 11, 2009 Share Posted December 11, 2009 As far as I can tell there's no errors in that code. Quote Link to comment https://forums.phpfreaks.com/topic/184783-undefined-constant-error-in-wampserver/#findComment-975613 Share on other sites More sharing options...
wdallman Posted December 12, 2009 Author Share Posted December 12, 2009 Thanks. I've worked around the problem. Thanks again for looking. Quote Link to comment https://forums.phpfreaks.com/topic/184783-undefined-constant-error-in-wampserver/#findComment-975956 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.