Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PHP Help
#1
I am getting an unexpected '}' error on line 21, but on line 21, I NEED that '}' to end the function! What should I do?

<?php

ini_set ('diplay_errors', 1); //set the system to display errors. (SOOO USEFUL)

$num = rand(1,8); //assign the variable
//start the function, while using elseif to save space.
if ($num == 1) {
print "<p>You got number 1, DOES THAT MEAN YOU ARE?</p>";
} elseif ($num == 2) {
print "<p>Number 2, you got second my young student</p>";
} elseif ($num == 3) {
print "<p>Magic number, 3 is. -Master Yoda</p>";
} elseif ($num == 4) {
print "<p>4, or for. You decide.</p>";
} elseif ($num == 5) {
print "<p>You has 5 fingers. OR DO YOU?</p>";
} elseif ($num == 6) {
print "<p>6? 666? Oh dear lord what have I done? O_O</p>";
} elseif ($num == 7) {
print "<p>7! You lucky boy! Or girl, how the hell should I know?</p>";
} else ($num == 8) {
print "<p>You got 8! You win the prize! Call 1-800-YOU-FAIL for your FREE prize!</p>";
}

?>
[Image: chaosthegreat.png]
Reply
#2
Make the "else" into "elseif".
Lol and those aren't called functions...
Reply
#3
elseif and if are functions...

Also, thank you.
[Image: chaosthegreat.png]
Reply
#4
A function in PHP is this:

Code:
function eatCheese($whatKind) {
echo "I just ate $whatKind cheese!!!";
}

eatCheese("Swiss");

xD
Reply
#5
Well then I will get technical, STATEMENT.

I guess I just learned to know them as functions. Whatever.
[Image: chaosthegreat.png]
Reply
#6
If you wanna get technical, the proper way of saying it would be, "I need the '}' to signify the end of the code fragment that's executed conditionally." :p
Reply
#7
Do you live to make me confused?
[Image: chaosthegreat.png]
Reply
#8
Lolno.

It's not that complicated once you read it over and over and analyze every few words. xD
Reply
#9
I think a switch would work better for that.
Reply
#10
Yes, a switch.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)