dink87522 Posted August 9, 2009 Share Posted August 9, 2009 <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Random name generator</title> </head> <body> <?php $first_name[1] = "Mark"; $first_name[2] = "David"; $first_name[3] = "Connor"; $first_name[4] = "John"; $first_name[5] = "Michae;l" $last_name[1] = "Barnes"; $last_name[2] = "Smith"; $last_name[3] = "Potts"; $last_name[4] = "White"; $last_name[5] = "Menitt"; echo("<h4>Random name generator</h4><p>"); $random_first = rand(1, 5); $random_last = rand(1, 5); name$ = $first_name[$random_first]." ".$last_name[$random_last]; echo("<h4>Random name: name$</h4>") ?> </body> </html> Parse error: syntax error, unexpected T_VARIABLE in /home/dinksoft/public_html/randomNameGenerator.php on line 13 however I cannot see anything wrong with it (first time with this error before also). Link to comment https://forums.phpfreaks.com/topic/169476-solved-t_variable-error/ Share on other sites More sharing options...
RichardRotterdam Posted August 9, 2009 Share Posted August 9, 2009 what's not right on the following $first_name[5] = "Michae;l" notice how the final character in that line is not a semicolon? Link to comment https://forums.phpfreaks.com/topic/169476-solved-t_variable-error/#findComment-894159 Share on other sites More sharing options...
dink87522 Posted August 9, 2009 Author Share Posted August 9, 2009 Thanks, I feel stupid now lol. I just couldn't see that. Link to comment https://forums.phpfreaks.com/topic/169476-solved-t_variable-error/#findComment-894160 Share on other sites More sharing options...
dink87522 Posted August 9, 2009 Author Share Posted August 9, 2009 Parse error: syntax error, unexpected T_BREAK in /home/dinksoft/public_html/deckShuffler.php on line 67 <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Deck Shuffler</title> </head> <body> <!-- Simulates the shuffling of a standard 52 card deck and deals one random card --> <?php $cardNumber = rand(1, 13); // 1 = Ace, 11 = Jack, 12 = Queen, 13 = King, all others equal their face value $cardSuit = rand(1, 4); // 1 = Hearts, 2 = Diamonds, 3 = Spades, 4 = Clubs switch ($cardNumber){ case "1": $card = "Ace"; break; case "2": $card = "Two"; break; case "3": $card = "Three"; break; case "4": $card = "Four"; break; case "5": $card = "Five"; break; case "6": $card = "Six"; break; case "7": $card = "Seven"; break; case "8": $card = "Eight"; break; case "9": $card = "Nine"; break; case "10": $card = "Ten"; break; case "11": $card = "Jack"; break; case "12": $card = "Queen"; break; case "13": $card = "King"; break; } // Identifies the card suit switch ($cardSuit){ case "1": $suit = "Hearts"; break; case "2": $suit = "Diamonds"; break; case "3": $suit = "Spades"; break; case "4": $suit = "Clubs"; break; } echo("Card dealt: $card of $suit") ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/169476-solved-t_variable-error/#findComment-894161 Share on other sites More sharing options...
dink87522 Posted August 9, 2009 Author Share Posted August 9, 2009 I fixed it by removing that last break statement in the second switch. Why did this fix it though? As http://www.tizag.com/phpT/switch.php shows it as being acceptable as having a break there. Link to comment https://forums.phpfreaks.com/topic/169476-solved-t_variable-error/#findComment-894165 Share on other sites More sharing options...
RichardRotterdam Posted August 9, 2009 Share Posted August 9, 2009 I fixed it by removing that last break statement in the second switch. Why did this fix it though? As http://www.tizag.com/phpT/switch.php shows it as being acceptable as having a break there. Hmm odd I actually ran the script you posted and it doesn't produce any parsing errors. Link to comment https://forums.phpfreaks.com/topic/169476-solved-t_variable-error/#findComment-894167 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.