Avatar billede optur Novice
01. juni 2010 - 20:34 Der er 9 kommentarer og
1 løsning

Use of undefined constant

min side virker på localhost, samt på min egen www linux server, men på vores eksamens server før jeg følgende fejl:

Notice: Use of undefined constant about - assumed 'about' in D:\Users\EAMV201015\index.php on line 42>Om søndergård

Notice: Use of undefined constant home - assumed 'home' in D:\Users\EAMV201015\include\function.php  on line 78

om mange flere ligende:

linje 42 min index ser sådan her ud:
<li><a href="<?php $_SERVER['PHP_SELF'];?>?table=about"<?php if($table==about) { ?> style="text-decoration:underline" <?php } ?>>Om s&oslash;nderg&aring;rd</a></li>

hvad gør jeg forkert? nedenfor er mere udspecificeret kode.


Min index.php

<?php

// Denne funktion gør at teksten bliver pakke så meget sammen som muligt
function callback($buffer)
{
$holdit=$buffer;
$strip1 = array(" ","\n","\r");
$strip2 = array(" ","","");
$holdit=str_replace($strip1,$strip2, $holdit);
return $holdit;
}

header("Content-language: da");
header("Cache-Control: public");
header("Pragma: public");
header("Expires: Thu, 20 Aug 2065 23:59:59 GMT");
// gzipper sitet
ob_start("ob_gzhandler");
// køre funktionen callback
ob_start("callback");

//inkludere filen function.php
include('./include/function.php');
// XML
echo '<?xml version="1.0" encoding="utf-8"?>';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="da">
<head>
<link rel="stylesheet" href="include/style.css" type="text/css" media="all" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>B&oslash;rnehaven S&oslash;nderg&aring;rd</title>
</head>
<body>
<!-- boksen som rummer sitet -->
<div id="container">
<a href="<?php $_SERVER['PHP_SELF'];?>?table=home"><img src="images/logo.png" id="logo" width="123" height="92" alt="Logo" /></a>
<!-- øverste boks som indeholder hovedmenu -->
<div id="headernavi">
<!-- horisontal UL til hovedmenu punkterne -->
<ul id="headernavilist">
<li><a href="<?php $_SERVER['PHP_SELF'];?>?table=about"<?php if($table==about) { ?> style="text-decoration:underline" <?php } ?>>Om s&oslash;nderg&aring;rd</a></li>
<li><a href="<?php $_SERVER['PHP_SELF'];?>?table=everyday"<?php if($table==everyday) { ?> style="text-decoration:underline" <?php } ?>>Hverdag</a></li>
<li><a href="<?php $_SERVER['PHP_SELF'];?>?table=staff"<?php if($table==staff) { ?> style="text-decoration:underline" <?php } ?>>Personale</a></li>
<li><a href="<?php $_SERVER['PHP_SELF'];?>?table=parents"<?php if($table==parents) { ?> style="text-decoration:underline" <?php } ?>>For&aelig;ldrebestyrelsen</a></li>
<li><a href="<?php $_SERVER['PHP_SELF'];?>?table=official"<?php if($table==official) { ?> style="text-decoration:underline" <?php } ?>>Officielt</a></li>
<li><a href="<?php $_SERVER['PHP_SELF'];?>?table=gallery"<?php if($table==gallery) { ?> style="text-decoration:underline" <?php } ?>>Billedgalleri</a></li>
<li><a href="<?php $_SERVER['PHP_SELF'];?>?static=contact"<?php if($static==contact) { ?> style="text-decoration:underline" <?php } ?>>Kontakt</a></li>
</ul>    </div>
<!-- indeholder trækronen som et background -->
<div id="treetop"></div>
<!-- wrapper til sidemenu og content. Indeholder træstamme som baggrund der høre repeat i venstre side som udvidere sig med indholdet og menu -->
<div id="filler">
<?php content($static,$table,$id); ?>
</div>
<!-- indeholder kalender, login som går igen på alle sider -->
<div id="sidebar">
<?php include("calendarix/minical.php"); ?><br />
<a href=".<?php $_SERVER['PHP_SELF'];?>?static=login">Personale Login</a>
</div>
<!-- footer med kontakt info til børnehaven -->
<div id="footer"></div>
</div>

</body>
</html>


min function.php:
<?php
include('db_con.php');


// henter variablen id
$id = isset($_GET['id']);
$table = isset($_GET['table']);
$static = isset($_GET['static']);

function content($static,$table,$id) {
switch ($table) {
case home:
echo 'lidt indhold';
break;
case about:    ?>
<ul id="navilist">
<li><a href="<?php $_SERVER['PHP_SELF'];?>?table=<?php echo $table ?>&amp;id=2"<?php if($table==about&$id==2) { ?> style="text-decoration:underline" <?php } ?>>Her bor vi<img src="images/gren.png" class="branch" width="187" height="30" alt="gren" /></a></li>
<li><a href="<?php $_SERVER['PHP_SELF'];?>?table=<?php echo $table ?>&amp;id=3"<?php if($table==about&$id==3) { ?> style="text-decoration:underline" <?php } ?>>Lokaler og indretning<img src="images/gren.png" class="branch" width="187" height="30" alt="gren" /></a></li>
<li><a href="<?php $_SERVER['PHP_SELF'];?>?table=<?php echo $table ?>&amp;id=4"<?php if($table==about&$id==4) { ?> style="text-decoration:underline" <?php } ?>>Principper og v&aelig;rdier<img src="images/gren.png" class="branch" width="187" height="30" alt="gren" /></a></li>
<li><a href="<?php $_SERVER['PHP_SELF'];?>?table=<?php echo $table ?>&amp;id=5"<?php if($table==about&$id==5) { ?> style="text-decoration:underline" <?php } ?>>Omr&aring;deledelses generelt<img src="images/gren.png" class="branch" width="187" height="30" alt="gren" /></a></li>
<li><a href="<?php $_SERVER['PHP_SELF'];?>?table=<?php echo $table ?>&amp;id=6"<?php if($table==about&$id==6) { ?> style="text-decoration:underline" <?php } ?>>B&oslash;rnemilj&oslash;vurdering<img src="images/gren.png" class="branch" width="187" height="30" alt="gren" /></a></li>
<li><a href="<?php $_SERVER['PHP_SELF'];?>?table=<?php echo $table ?>&amp;id=7"<?php if($table==about&$id==7) { ?> style="text-decoration:underline" <?php } ?>>Traditioner<img src="images/gren.png" class="branch" width="187" height="30" alt="gren" /></a></li>
<li><a href="<?php $_SERVER['PHP_SELF'];?>?table=<?php echo $table ?>&amp;id=8"<?php if($table==about&$id==8) { ?> style="text-decoration:underline" <?php } ?>>Praktikstedsbeskrivelse<img src="images/gren.png" class="branch" width="187" height="30" alt="gren" /></a></li>
</ul>
<?php
include('include/content.php');
break;
case everyday: ?>
<ul id="navilist">
<li><a href="<?php $_SERVER['PHP_SELF'];?>?table=<?php echo $table ?>&amp;id=2"<?php if($table==everyday&$id==2) { ?> style="text-decoration:underline" <?php } ?>>B&oslash;rnehaven i hverdagen<img src="images/gren.png" class="branch" width="187" height="30" alt="gren" /></a></li>
<li><a href="<?php $_SERVER['PHP_SELF'];?>?table=<?php echo $table ?>&amp;id=3"<?php if($table==everyday&$id==3) { ?> style="text-decoration:underline" <?php } ?>>Madpolitik<img src="images/gren.png" class="branch" width="187" height="30" alt="gren" /></a></li>
<li><a href="<?php $_SERVER['PHP_SELF'];?>?table=<?php echo $table ?>&amp;id=4"<?php if($table==everyday&$id==4) { ?> style="text-decoration:underline" <?php } ?>>&Aring;rsplan<img src="images/gren.png" class="branch" width="187" height="30" alt="gren" /></a></li>
<li><a href="<?php $_SERVER['PHP_SELF'];?>?table=<?php echo $table ?>&amp;id=5"<?php if($table==everyday&$id==5) { ?> style="text-decoration:underline" <?php } ?>>Virksomhedsplan<img src="images/gren.png" class="branch" width="187" height="30" alt="gren" /></a></li>
<li><a href="<?php $_SERVER['PHP_SELF'];?>?table=<?php echo $table ?>&amp;id=6"<?php if($table==everyday&$id==6) { ?> style="text-decoration:underline" <?php } ?>>Sprogstimulering<img src="images/gren.png" class="branch" width="187" height="30" alt="gren" /></a></li>
<li><a href="<?php $_SERVER['PHP_SELF'];?>?table=<?php echo $table ?>&amp;id=8"<?php if($table==everyday&$id==7) { ?> style="text-decoration:underline" <?php } ?>>Inklusion (s&aring;rbare b&oslash;rn)<img src="images/gren.png" class="branch" width="187" height="30" alt="gren" /></a></li>
</ul>
<?php
include('include/content.php');
break;
}
}
Avatar billede tjens Nybegynder
01. juni 2010 - 21:01 #1
Jeg kan heller ikke se hvor about er defineret
<?php if($table==about) { ?>
Skulle det være en string, variabel eller konstant?
Avatar billede majbom Novice
01. juni 2010 - 21:03 #2
medmindre du har defineret "about" tidligere, kan den ikke finde ud af hvad dette betyder.

du skal indkapsle strenge i " eller ' ellers tror php det er en konstant

og selvfølgelig det samme med "home"
Avatar billede majbom Novice
01. juni 2010 - 21:03 #3
der var jeg sq for langsom :)
Avatar billede optur Novice
01. juni 2010 - 22:29 #4
problemet er at den er variabel, det kommer an på hvilket menupunkt der bliver valgt, hver har deres tabel navn, som så henter en database tabel ved samme navn. hvordan får jeg det ind så alle tabelnavnene er "godkendte" og alle mine stenge skulle helst gerne være i '' eller ""
Avatar billede majbom Novice
01. juni 2010 - 22:36 #5
forstår dig ikke lige, men prøv at ret:


<li><a href="<?php $_SERVER['PHP_SELF'];?>?table=about"<?php if($table==about) { ?> style="text-decoration:underline" <?php } ?>>Om s&oslash;nderg&aring;rd</a></li>


til:


<li><a href="<?php $_SERVER['PHP_SELF'];?>?table=about"<?php if($table=="about") { ?> style="text-decoration:underline" <?php } ?>>Om s&oslash;nderg&aring;rd</a></li>
Avatar billede majbom Novice
01. juni 2010 - 22:37 #6
okay, den cutter så noget af  linjerne...


<li><a href="<?php $_SERVER['PHP_SELF'];?>?table=about"<?php if($table==about) { ?> style="text-decoration:underline" <?php } ?>>Om s&oslash;nderg&aring;rd</a></li>


til:


<li><a href="<?php $_SERVER['PHP_SELF'];?>?table=about"<?php if($table=="about") { ?> style="text-decoration:underline" <?php } ?>>Om s&oslash;nderg&aring;rd</a></li>
Avatar billede optur Novice
01. juni 2010 - 22:46 #7
Nu er jeg HELT med i hvad i mente... i skal have så uendelige mange tak for hjælpen.
Avatar billede majbom Novice
01. juni 2010 - 22:51 #8
selv tak :)

vi må lige have et svar fra tjens osse...
Avatar billede tjens Nybegynder
01. juni 2010 - 23:10 #9
Giv bare splazz alle point.
Avatar billede majbom Novice
02. juni 2010 - 20:53 #10
takker!
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester