Kan ikke finde fejlen

Tags:    php

<< < 12 > >>
Hvad er der i vejen med nedenstående kode? Fil- og mapperettighederne er i orden, sååå..
Hjælp mig :'( Snøft
<
<
<
$randrace = mt_rand(1, 4);
$randhero = mt_rand(1, 4);
$randspeak = mt_rand(1, 2);
$racearray = array('hmn','orc','ne','ud');
$hmnheroarray = array('Mountain King,hmk','Blood Mage,hbm','Archmage,ha','Paladin,hp');
$orcheroarray = array('Shadow Hunter,osh','Tauren Chieftain,otc','Far Seer,ofs','Blademaster,obm');
$neheroarray = array('Demon Hunter,ndh','Priestess of the Moon,npotm','Keeper of the Grove,nkotg','Warden,nw');
$udheroarray = array('Undead Knight,uuk','Dread Lord,udl','Lich,ul','Crypt Lord,ucl');
function makeBox() {
switch( $racearray[$randrace] ) {
case "hmn":
$race = "hmn";
$heroname = explode(",",$hmnheroarray[$randhero]);
$heroname = $heroname[1];
$filename = $heroname[2];
break;
case "orc":
$race = "orc";
$heroname = explode(",",$orcheroarray[$randhero]);
$heroname = $heroname[1];
$filename = $heroname[2];
break;
case "ne":
$race = "ne";
$heroname = explode(",",$neheroarray[$randhero]);
$heroname = $heroname[1];
$filename = $heroname[2];
break;
case "ud":
$race = "ud";
$heroname = explode(",",$udheroarray[$randhero]);
$heroname = $heroname[1];
$filename = $heroname[2];
break;
default:
echo "Error happened!?";
}
$filename = "/speak/" . $filename . ".txt";
$speak = file($filename);
$speak = $speak[$randspeak];
return(array($speak,$heroname,$race));
}
>
>
>

MVH. qff



14 svar postet i denne tråd vises herunder
2 indlæg har modtaget i alt 6 karma
Sorter efter stemmer Sorter efter dato
det tyder på at der ikke bliver gemt noget i $filename

Hilsen Chadi
Mit lykketal er 2959

Ja der bliver hverken gemt noget $race, $heroname og $filename.
Og selvom man laver dem til globals(AC's idé) virker det heller ikke.
MVH. qff



Prøv:


$randrace = mt_rand(1, 4)-1;
$randhero = mt_rand(1, 4)-1;
$randspeak = mt_rand(1, 2)-1;
$racearray = array('hmn','orc','ne','ud');
$hmnheroarray = array('Mountain King,hmk','Blood Mage,hbm','Archmage,ha','Paladin,hp');
$orcheroarray = array('Shadow Hunter,osh','Tauren Chieftain,otc','Far Seer,ofs','Blademaster,obm');
$neheroarray = array('Demon Hunter,ndh','Priestess of the Moon,npotm','Keeper of the Grove,nkotg','Warden,nw');
$udheroarray = array('Undead Knight,uuk','Dread Lord,udl','Lich,ul','Crypt Lord,ucl');
function makeBox() {
global $randrace, $randhero, $randspeak, $racearray, $hmnheroarray, $orcheroarray, $neheroarray, $udheroarray;
switch( $racearray[$randrace] ) {
case "hmn":
$race = "hmn";
$heroname = explode(",",$hmnheroarray[$randhero]);
$filename = $heroname[1];
$heroname = $heroname[0];
break;
case "orc":
$race = "orc";
$heroname = explode(",",$orcheroarray[$randhero]);
$filename = $heroname[1];
$heroname = $heroname[0];
break;
case "ne":
$race = "ne";
$heroname = explode(",",$neheroarray[$randhero]);
$filename = $heroname[1];
$heroname = $heroname[0];
break;
case "ud":
$race = "ud";
$heroname = explode(",",$udheroarray[$randhero]);
$filename = $heroname[1];
$heroname = $heroname[0];
break;
default:
echo "Error happened!?";
}
$filename = "/speak/" . $filename . ".txt";
$speak = file($filename);
$speak = $speak[$randspeak];
return(array($speak,$heroname,$race));
}


/AC



Prøv:

...

/AC

Mange tak AC det virker nu :D (efter nogle små justeringer og fejl fra min egen side)

MVH. qff



np :)


/AC



<< < 12 > >>
t