Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    Regular Coder
    Join Date
    Jan 2010
    Posts
    127
    Thanks
    9
    Thanked 0 Times in 0 Posts

    undefined constant home

    i got this error

    Notice: Use of undefined constant home - assumed 'home' in C:\wamp\www\gunungraya\index.php on line 8

    when i using localhost view my file, but once i upload into hosting it just go normal, meaning i view the site without the error msg

    if i view with "http://127.0.0.1/gunungraya/"
    come out this error
    Notice: Use of undefined constant home - assumed 'home' in C:\wamp\www\gunungraya\index.php on line 8

    if i view with "http://example.com/gunungraya/"
    no error come out

    below is my code
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <?php
    function title_switch(){
    $var = (isset($_GET['page']) && !empty($_GET['page']))?$_GET['page']:home;
        switch( 
    $var ) {
            case 
    'home'
                
    $a['title'] = " » Homepage"
                
    $a['meta_d'] = "This page is about my site!"
                
    $a['meta_k'] = "something, somethingelse";
                
    $a['nivo'] = "<script src=\"./js/jquery.nivo.slider.pack.js\" type=\"text/javascript\"></script>\n";
                
    $a['nivo_css'] = "<link href=\"./css/nivo-slider.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n";
                break;
            case 
    'about'
                
    $a['title'] = " » About Us"
                
    $a['meta_d'] = "This page is about my site!"
                
    $a['meta_k'] = "something, somethingelse";
                break;
            case 
    'services'
                
    $a['title'] = " » Services"
                
    $a['meta_d'] = "This page is about my site!"
                
    $a['meta_k'] = "something, somethingelse";
                break;
            case 
    'gallery'
                
    $a['title'] = " » Gallery"
                
    $a['meta_d'] = "This page is about my site!"
                
    $a['meta_k'] = "something, somethingelse";
                break;
            case 
    'contact'
                
    $a['title'] = " » Contact Us"
                
    $a['meta_d'] = "This page is about my site!"
                
    $a['meta_k'] = "something, somethingelse";
                break;
            default: 
                
    $a['title'] = " » HTTP 404 - Page Not Found"
                
    $a['meta_d'] = ""
                
    $a['meta_k'] = "";
                break;
        }
        return 
    $a;
    }
    $details title_switch();
    ?>
    <meta content="<?php echo $details['meta_k']; ?>" name="keywords" />
    <meta content="<?php echo $details['meta_d']; ?>" name="description" />
    <link href="images/favicon.ico" rel="shortcut icon" />
    <link href="./css/style.css" rel="stylesheet" type="text/css" />
    <link href="./css/pirobox_lightbox.css" rel="stylesheet" type="text/css" />
    <script src="./js/jquery.min.js" type="text/javascript"></script>
    <script src="./js/jquery.easing.1.3.js" type="text/javascript"></script>
    <script src="./js/pirobox.min.js" type="text/javascript"></script>
    <script src="./js/global.js" type="text/javascript"></script>
    <?php echo $details['nivo_css']; ?><?php echo $details['nivo']; ?>
    <title>Gunung Raya Five Star Express<?php echo $details['title']; ?></title>
    </head>

    <body>
    <!-- :::: Begin Sidebar Navigation :::: -->
    <div class="container">
    <div id="sidenav">
        <a href="./" title="Gunung Raya Five Star Express"><img alt="" class="logo" src="images/logo.gif" /></a>
            <!-- :::: Main Navigation :::: -->
            <ul>
                <li><a class="home" href="./?page=about">About Us</a></li>
                <li><a class="services" href="./?page=services">Services &amp; Rates</a></li>
                <li><a class="gallery" href="./?page=gallery">Gallery</a></li>
                <li><a class="contact" href="./?page=contact" style="border-bottom: 0;">Contact Us</a></li>
            </ul>
            <!-- :::: Social Navigation :::: -->
            <div id="social">
                <div class="social_facebook">
                    <a href="http://www.facebook.com/" title="">&nbsp;</a></div>
                <div class="social_twitter">
                    <a href="http://www.twitter.com/" title="">&nbsp;</a></div>
                <div class="social_lastfm">
                    <a href="http://www.last.fm/" title="">&nbsp;</a></div>
                <div class="social_flickr">
                    <a href="http://www.flickr.com/" title="">&nbsp;</a></div>
                </div>
            <!-- :::: Site Copyright :::: -->
        <div id="footer">© Your Name Here 2010</div>
    </div>
    <!-- :::: End Sidebar Navigation :::: -->
    <!-- :::: Begin Content :::: -->
    <div id="content">
        <?php
            $pass 
    = array('home','about','services','gallery','contact');
            if (
    in_array(@$_GET['page'], $pass)) { 
                include (
    $_SERVER['DOCUMENT_ROOT'] . '/gunungraya/page/' $_GET['page'] . '.php'); 
            } 
                elseif (!isset(
    $_GET['page'])) { 
                    include (
    $_SERVER['DOCUMENT_ROOT'] . '/gunungraya/page/home.php'); 
                } 
                   else { 
                     include (
    $_SERVER['DOCUMENT_ROOT'] . '/gunungraya/page/error.php'); 
                } 
        
    ?>
    </div>
    </div>

    </body>

    </html>
    pls help me where did i go wrong

    my file is in wamp --> www --> gunungraya

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    when i using localhost view my file, but once i upload into hosting it just go normal, meaning i view the site without the error msg

    if i view with "http://127.0.0.1/gunungraya/"
    come out this error
    Notice: Use of undefined constant home - assumed 'home' in C:\wamp\www\gunungraya\index.php on line 8

    if i view with "http://example.com/gunungraya/"
    no error come out
    The error reporting might be OFF at your server. Check the output of phpinfo(); at both ends.

    Changing
    !empty($_GET['page']))?$_GET['page']:home;
    to
    Code:
    !empty($_GET['page']))?$_GET['page']:'home';
    would sort it out.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder
    Join Date
    Jan 2010
    Posts
    127
    Thanks
    9
    Thanked 0 Times in 0 Posts
    thanks for your fast reply, but now i got this error if i open about.php


    Notice: Undefined index: nivo_css in C:\wamp\www\gunungraya\index.php on line 56

    Notice: Undefined index: nivo in C:\wamp\www\gunungraya\index.php on line 56

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    <?php echo $details['nivo_css']; ?><?php echo $details['nivo']; ?>
    You need to use the isset() function before using any variable. Or you may turn off such notices by changing the ini settings.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    Regular Coder
    Join Date
    Jan 2010
    Posts
    127
    Thanks
    9
    Thanked 0 Times in 0 Posts
    sorry im kinda new in php, how do i do like what you say?

    PHP Code:
    <?php echo ($details['nivo_css'];) ?>
    like this?

  • #6
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    PHP Code:
    if(isset($var)) echo $var
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #7
    Regular Coder
    Join Date
    Jan 2010
    Posts
    127
    Thanks
    9
    Thanked 0 Times in 0 Posts
    where should i put it?

  • #8
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Um.. change
    <?php echo $details['nivo_css']; ?><?php echo $details['nivo']; ?>
    to
    PHP Code:
    <?php
    if(isset($_GET['page']))
    echo 
    $details['nivo_css'].$details['nivo']; 
    ?>
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #9
    Regular Coder
    Join Date
    Jan 2010
    Posts
    127
    Thanks
    9
    Thanked 0 Times in 0 Posts
    bro i still got this error

    Code:
    Notice: Undefined index: nivo_css in C:\wamp\www\gunungraya\index.php on line 49
    
    Notice: Undefined index: nivo in C:\wamp\www\gunungraya\index.php on line 49
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <?php
    function title_switch(){
    $var = (isset($_GET['page']) && !empty($_GET['page']))?$_GET['page']:'home';
        switch( 
    $var ) {
            case 
    'home'
                
    $a['title'] = " » Homepage"
                
    $a['meta_d'] = "This page is about my site!"
                
    $a['meta_k'] = "something, somethingelse";
                
    $a['nivo'] = "<script src=\"./js/jquery.nivo.slider.pack.js\" type=\"text/javascript\"></script>\n";
                
    $a['nivo_css'] = "<link href=\"./css/nivo-slider.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n";
                break;
            case 
    'about'
                
    $a['title'] = " » About Us"
                
    $a['meta_d'] = "This page is about my site!"
                
    $a['meta_k'] = "something, somethingelse";
                break;
            case 
    'services'
                
    $a['title'] = " » Services"
                
    $a['meta_d'] = "This page is about my site!"
                
    $a['meta_k'] = "something, somethingelse";
                break;
            case 
    'gallery'
                
    $a['title'] = " » Gallery"
                
    $a['meta_d'] = "This page is about my site!"
                
    $a['meta_k'] = "something, somethingelse";
                break;
            case 
    'contact'
                
    $a['title'] = " » Contact Us"
                
    $a['meta_d'] = "This page is about my site!"
                
    $a['meta_k'] = "something, somethingelse";
                break;
            default: 
                
    $a['title'] = " » HTTP 404 - Page Not Found"
                
    $a['meta_d'] = ""
                
    $a['meta_k'] = "";
                break;
        }
        return 
    $a;
    }
    $details title_switch();
    ?>
    <?php
        
    if(isset($_GET['page']))
        echo 
    $details['nivo_css'].$details['nivo']; 
    ?> 
    <meta content="<?php echo $details['meta_k']; ?>" name="keywords" />
    <meta content="<?php echo $details['meta_d']; ?>" name="description" />
    <link href="images/favicon.ico" rel="shortcut icon" />
    <link href="./css/style.css" rel="stylesheet" type="text/css" />
    <link href="./css/pirobox_lightbox.css" rel="stylesheet" type="text/css" />
    <script src="./js/jquery.min.js" type="text/javascript"></script>
    <script src="./js/jquery.easing.1.3.js" type="text/javascript"></script>
    <script src="./js/pirobox.min.js" type="text/javascript"></script>
    <script src="./js/global.js" type="text/javascript"></script>
    <title>Gunung Raya Five Star Express<?php echo $details['title']; ?></title>
    </head>

    <body>
    <!-- :::: Begin Sidebar Navigation :::: -->
    <div class="container">
    <div id="sidenav">
        <a href="./" title="Gunung Raya Five Star Express"><img alt="" class="logo" src="./images/logo.png" /></a>
            <!-- :::: Main Navigation :::: -->
            <ul>
                <li><a class="home" href="./?page=about">About Us</a></li>
                <li><a class="services" href="./?page=services">Services &amp; Rates</a></li>
                <li><a class="gallery" href="./?page=gallery">Gallery</a></li>
                <li><a class="contact" href="./?page=contact" style="border-bottom: 0;">Contact Us</a></li>
            </ul>
            <!-- :::: Social Navigation :::: -->
            <div id="social">
                <div class="social_facebook">
                    <a href="http://www.facebook.com/" title="">&nbsp;</a></div>
                <div class="social_twitter">
                    <a href="http://www.twitter.com/" title="">&nbsp;</a></div>
                </div>
            <!-- :::: Site Copyright :::: -->
        <div id="footer">© Your Name Here 2010</div>
    </div>
    <!-- :::: End Sidebar Navigation :::: -->
    <!-- :::: Begin Content :::: -->
    <div id="content">
        <?php
            $pass 
    = array('home','about','services','gallery','contact');
            if (
    in_array(@$_GET['page'], $pass)) { 
                include (
    $_SERVER['DOCUMENT_ROOT'] . '/gunungraya/page/' $_GET['page'] . '.php'); 
            } 
                elseif (!isset(
    $_GET['page'])) { 
                    include (
    $_SERVER['DOCUMENT_ROOT'] . '/gunungraya/page/home.php'); 
                } 
                   else { 
                     include (
    $_SERVER['DOCUMENT_ROOT'] . '/gunungraya/page/error.php'); 
                } 
        
    ?>
    </div>
    </div>

    </body>

    </html>

  • #10
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Change:

    Code:
    }
    $details = title_switch();
    ?>
    <?php
        if(isset($_GET['page']))
        echo $details['nivo_css'].$details['nivo']; 
    ?>
    to:

    Code:
    }
    $details = title_switch();
    
    if (isset($details['nivo_css']) && isset($details['nivo']))
    {
        echo $details['nivo_css'].$details['nivo']; 
    }
    ?>

  • #11
    Regular Coder
    Join Date
    Jan 2010
    Posts
    127
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by MattF View Post
    Change:

    Code:
    }
    $details = title_switch();
    ?>
    <?php
        if(isset($_GET['page']))
        echo $details['nivo_css'].$details['nivo']; 
    ?>
    to:

    Code:
    }
    $details = title_switch();
    
    if (isset($details['nivo_css']) && isset($details['nivo']))
    {
        echo $details['nivo_css'].$details['nivo']; 
    }
    ?>
    bro this code work but it crash my plugin.. i dunno why... but from what i see from the source code is like this

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <link href="./css/nivo-slider.css" media="screen" rel="stylesheet" type="text/css" />
    <script src="./js/jquery.nivo.slider.pack.js" type="text/javascript"></script>
    <meta content="something, somethingelse" name="keywords" />
    <meta content="This page is about my site!" name="description" />
    <link href="images/favicon.ico" rel="shortcut icon" />
    <link href="./css/style.css" rel="stylesheet" type="text/css" />
    <link href="./css/pirobox_lightbox.css" rel="stylesheet" type="text/css" />
    <script src="./js/jquery.min.js" type="text/javascript"></script>
    <script src="./js/jquery.easing.1.3.js" type="text/javascript"></script>
    
    <script src="./js/pirobox.min.js" type="text/javascript"></script>
    <script src="./js/global.js" type="text/javascript"></script>
    <title>Gunung Raya Five Stars Express &#187; Homepage</title>
    </head>
    pls help

  • #12
    Regular Coder
    Join Date
    Jan 2010
    Posts
    127
    Thanks
    9
    Thanked 0 Times in 0 Posts
    any help?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •