Coconut99
07-02-2003, 06:37 PM
I'm trying to make a name generator using PHP with two parts: the name and an adjective. Whenever I try to display the results with echo(), I get parse errors. This is my code so far:
<?
//GET ARRAYS
$name_array = file("names.txt");
$adj_array = file("adjs.txt");
//SET VARS
$random_name = array_rand ($name_array, 1);
$random_adj = array_rand ($adj_array, 1);
?>
When I run this, I get no errors but nothing else, either. (The above code could be wrong, anyway.) How should/can I display the finished product? Thanks in advance!
Edit: For instance, when I try:
<?
echo("$random_name $random_adj");
?>
I get: Parse error: parse error, unexpected ';' in /home/virtual/site140/fst/var/www/html/php/goblins3.php on line 9.
<?
//GET ARRAYS
$name_array = file("names.txt");
$adj_array = file("adjs.txt");
//SET VARS
$random_name = array_rand ($name_array, 1);
$random_adj = array_rand ($adj_array, 1);
?>
When I run this, I get no errors but nothing else, either. (The above code could be wrong, anyway.) How should/can I display the finished product? Thanks in advance!
Edit: For instance, when I try:
<?
echo("$random_name $random_adj");
?>
I get: Parse error: parse error, unexpected ';' in /home/virtual/site140/fst/var/www/html/php/goblins3.php on line 9.