...

View Full Version : undefined constant home



lazyserv
11-03-2010, 04:53 PM
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

<!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'] = " &#187; 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'] = " &#187; About Us";
$a['meta_d'] = "This page is about my site!";
$a['meta_k'] = "something, somethingelse";
break;
case 'services':
$a['title'] = " &#187; Services";
$a['meta_d'] = "This page is about my site!";
$a['meta_k'] = "something, somethingelse";
break;
case 'gallery':
$a['title'] = " &#187; Gallery";
$a['meta_d'] = "This page is about my site!";
$a['meta_k'] = "something, somethingelse";
break;
case 'contact':
$a['title'] = " &#187; Contact Us";
$a['meta_d'] = "This page is about my site!";
$a['meta_k'] = "something, somethingelse";
break;
default:
$a['title'] = " &#187; 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

abduraooft
11-03-2010, 05:00 PM
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 (http://www.codingforums.com/showthread.php?p=617060#post617060) at your server. Check the output of phpinfo(); at both ends.

Changing
!empty($_GET['page']))?$_GET['page']:home; to

!empty($_GET['page']))?$_GET['page']:'home'; would sort it out.

lazyserv
11-03-2010, 05:16 PM
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

abduraooft
11-03-2010, 05:26 PM
<?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.

lazyserv
11-03-2010, 05:52 PM
sorry im kinda new in php, how do i do like what you say?


<?php echo ($details['nivo_css'];) ?>

like this?

abduraooft
11-03-2010, 05:59 PM
if(isset($var)) echo $var;

lazyserv
11-03-2010, 06:09 PM
where should i put it? :(

abduraooft
11-03-2010, 06:45 PM
Um.. change
<?php echo $details['nivo_css']; ?><?php echo $details['nivo']; ?> to

<?php
if(isset($_GET['page']))
echo $details['nivo_css'].$details['nivo'];
?>

lazyserv
11-04-2010, 03:30 AM
bro i still got this error


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


<!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'] = " &#187; 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'] = " &#187; About Us";
$a['meta_d'] = "This page is about my site!";
$a['meta_k'] = "something, somethingelse";
break;
case 'services':
$a['title'] = " &#187; Services";
$a['meta_d'] = "This page is about my site!";
$a['meta_k'] = "something, somethingelse";
break;
case 'gallery':
$a['title'] = " &#187; Gallery";
$a['meta_d'] = "This page is about my site!";
$a['meta_k'] = "something, somethingelse";
break;
case 'contact':
$a['title'] = " &#187; Contact Us";
$a['meta_d'] = "This page is about my site!";
$a['meta_k'] = "something, somethingelse";
break;
default:
$a['title'] = " &#187; 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>

MattF
11-04-2010, 04:51 AM
Change:



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


to:



}
$details = title_switch();

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

lazyserv
11-04-2010, 05:32 AM
Change:



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


to:



}
$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


<!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 :(

lazyserv
12-28-2010, 04:51 PM
any help? :(



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum