---
title: "Krångel med php"
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/55653-krångel-med-php"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "Nexus86"
published: "2002-10-10T13:26:19.000Z"
updated: "2002-10-10T13:59:50.000Z"
replies: 7
views: 276
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/php/55653-krångel-med-php"
---

# Krångel med php

## #1 — Nexus86, 2002-10-10T13:26Z

Det är något konstigt med ett av mina script. Först fungerar det och sedan inte sen efter ett tag fungerar det igen. någon som kan förklara? här är det:

```php
<?php

if (is_user($user)) {

require_once("mainfile.php");
get_lang("Games");

function menuimg($gfile) {
    $ThemeSel = get_theme();
    if (file_exists("themes/$ThemeSel/images/menu/$gfile")) {
	$menuimg = "themes/$ThemeSel/images/menu/$gfile";
    } else {
	$menuimg = "modules/Games/images/$gfile";
    }
    return($menuimg);
}

function nav($main_up=0) {
    global $module_name;
    $handle=opendir('themes');
    while ($file = readdir($handle)) {
	if ( (!ereg("[.]",$file)) ) {
		$thmcount++;
	}
    }
    closedir($handle);
    echo "<table border=\"0\" width=\"100%\" align=\"center\"><tr><td width=\"10%\">";

    $menuimg = menuimg("gamelinks.gif");
    echo "<font class=\"content\">"
	."<center><a href=\"modules.php?name=Games&amp;op=1\"><img src=\"$menuimg\" border=\"0\" alt=\""._GAMECHEATS."\"
title=\""._GAMECHEATS."\"></a><br>"
	."<a href=\"modules.php?name=Games&amp;op=1\">"._GAMECHEATS."</a>"
	."</center></font></td>";

    $menuimg = menuimg("downloads.gif");
    echo "<td width=\"10%\"><font class=\"content\">"
	."<center><a href=\"modules.php?name=Games&amp;op=2\"><img src=\"$menuimg\" border=\"0\" alt=\""._GAMEDOWNLOAD."\"
title=\""._GAMEDOWNLOAD."\"></a><br>"
	."<a href=\"modules.php?name=Downloads&amp;d_op=viewdownload&amp;cid=2\">"._GAMEDOWNLOAD."</a>"
	."</center></form></font></td>";

    $menuimg = menuimg("minigames.gif");
    echo "<td width=\"10%\"><font class=\"content\">"
	."<center><a href=\"modules.php?name=Games&amp;op=3\"><img src=\"$menuimg\" border=\"0\"
alt=\""._GAMEREVIEWSNEWS."\" title=\""._GAMEREVIEWSNEWS."\"></a><br>"
	."<a href=\"modules.php?name=Games&amp;op=3\">"._GAMEREVIEWSNEWS."</a>"
	."</center></form></font></td>";
	
    $menuimg = menuimg("cs.gif");
    echo "<td width=\"10%\"><font class=\"content\">"
	."<center><a href=\"modules.php?name=Games&amp;op=4\"><img src=\"$menuimg\" border=\"0\" alt=\"CS Serverstatus\"
title=\"CS Serverstatus\"></a><br>"
	."<a href=\"modules.php?name=Games&amp;op=4\">CS Serverstatus</a>"
	."</center></form></font></td>";

    echo "</td></tr></table>";
    if ($main_up != 1) {
	echo "<br><center>[ <a href=\"modules.php?name=Games\">"._RETURNGAMES."</a> ]</center>\n";
    }
}

}

if (!eregi("modules.php", $PHP_SELF)) {
	die ("You can't access this file directly...");
}

$module_name = basename(dirname(__FILE__));
get_lang($module_name);

$ThemeSel = get_theme();
#include("themes/$ThemeSel/theme.php");
include("header.php");
$headerdeclared = 1;

OpenTable();

if ($op != "") {
	nav(2);
	CloseTable();
	echo "<br>";
	if ($op == 1) {
		$l_op = "viewlink";
		$cid = 4;
		include("modules/Web_Links/index.php");
	} elseif ($op == 2) {
		$d_op = "viewdownload";
		$cid = 2;
		include("modules/Downloads/index.php");
	} elseif ($op == 3) {
		$new_topic = 4;
		include("modules/News/index.php");
	}
} else {
	echo "<center><font class=\"option\">"._GAMESTITLE."</font><br><br>"
	    ."<font class=\"content\">"._GAMESDESC."</font></center><br><br>\n";
	nav(1);
	CloseTable();
}

$index = 1;

include("footer.php");
?>
```

Permalänk: https://www.webforum.nu/p/55653

## #2 — Nexus86, 2002-10-10T13:32Z

Här är felmeddelandet:

**Fatal error**: Call to undefined function: **nav()** in **/home/httpd/vhosts/hiphopparz.com/httpdocs/modules/Games/index.php** on line **113**

För er som inte orkar räkna linjer kan jag säga att det är raden där det står: 

```php
nav(1);
```

Permalänk: https://www.webforum.nu/p/817922

## #3 — UrMe, 2002-10-10T13:44Z

Jag är inte den bästa på funktioner så rätta mig om jag är helt galen, men ska det verkligen stå så här:

```
function nav($main_up=0) {
```

den där $main_up=0 ser ju galen ut? .. ta bort =0

Permalänk: https://www.webforum.nu/p/817944

## #4 — Matte, 2002-10-10T13:48Z

> if (is_user($user)) {

 Om den här if-satsen returnerar false så kommer aldrig din funktion att deklareras.
Prova med att lägga funktionerna utanför if-satsen.

Permalänk: https://www.webforum.nu/p/817951

## #5 — Nexus86, 2002-10-10T13:50Z

\=0 skriver man för att om man inte skriver något annat så sätts värdet automatiskt till 0. Det är motsvarigheten mot ASP's Optional. Men jag kan prova. Jag sätter den iallafall alltid till nåt så varför inte?

Permalänk: https://www.webforum.nu/p/817952

## #6 — Nexus86, 2002-10-10T13:52Z

Fortfarande fel. Jag fattar inte varför men det är så. Mitt webbhotell säger att det iallafall inte är fel på servern. Så jag har ingen aning.

Permalänk: https://www.webforum.nu/p/817955

## #7 — Nexus86, 2002-10-10T13:58Z

Tack matte för tipset! Nu funkar det. Vill ni se resultatet finns det [här](http://www.hiphopparz.com/modules.php?name=Games).

Permalänk: https://www.webforum.nu/p/817957

## #8 — Gislaved.net, 2002-10-10T13:59Z

red: Det fixade sig ju...

Permalänk: https://www.webforum.nu/p/817959

---

Tråden på webben: https://www.webforum.nu/amne/php/55653-krångel-med-php
