Jump to content

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/184783-undefined-constant-error-in-wampserver/
Share on other sites

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.

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.

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>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.