Parse error: parse error, expecting `']'' - Not sure what the issue is...

I’m trying to make things easy on myself and rather than come up with names and dates to fill a database I wanted to just have PHP do that for me. The following code works just fine when I echo it.

[php]$year[rand(1, 3)]-$month[rand(1, 12)]-$day[rand(1, 28)][/php]

However now that I have that in a value area it does not work. If I replace rand with any number it seems to resolve the issue though.

This is the exact error I am getting:

Parse error: parse error, expecting `’]’’ in C:\Development Server\www\WebHosting\reviews-populate.php on line 158

Which I am guessing means I’m missing a ] somewhere, however I’m not. Here is the entire code I am using UP to the point where I’m getting the error.

[php]//Random Name Generator
$firstname = array(‘1’ => ‘James’,
‘2’ => ‘John’,
‘3’ => ‘Robert’,
‘4’ => ‘Michael’,
‘5’ => ‘William’,
‘6’ => ‘David’,
‘7’ => ‘Richard’,
‘8’ => ‘Charles’,
‘9’ => ‘Joe’,
‘10’ => ‘Thomas’,
‘11’ => ‘Chris’,
‘12’ => ‘Daniel’,
‘13’ => ‘Paul’,
‘14’ => ‘Mark’,
‘15’ => ‘Don’,
‘16’ => ‘George’,
‘17’ => ‘Ken’,
‘18’ => ‘Kevin’,
‘19’ => ‘Ron’,
‘20’ => ‘Eddie’,
‘21’ => ‘Larry’,
‘22’ => ‘Jeff’,
‘23’ => ‘Scott’,
‘24’ => ‘Eric’,
‘25’ => ‘Andrew’,
‘26’ => ‘Jason’,
‘27’ => ‘Dennis’,
‘28’ => ‘Peter’,
‘29’ => ‘Carl’,
‘30’ => ‘Roger’,
‘31’ => ‘Juan’,
‘32’ => ‘Justin’,
‘33’ => ‘Bruce’,
‘34’ => ‘Harry’,
‘35’ => ‘Adam’,
‘36’ => ‘Fred’,
‘37’ => ‘Billy’,
‘38’ => ‘Steve’,
‘39’ => ‘Eugene’,
‘40’ => ‘Carlos’,
‘41’ => ‘Mary’,
‘42’ => ‘Linda’,
‘43’ => ‘Maria’,
‘44’ => ‘Jennifer’,
‘45’ => ‘Lisa’,
‘46’ => ‘Carol’,
‘47’ => ‘Sharon’,
‘48’ => ‘Ann’,
‘49’ => ‘Stephanie’,
‘50’ => ‘Ashley’);
$lastname = array(‘1’ => ‘Smith’,
‘2’ => ‘Johnson’,
‘3’ => ‘Jonson’,
‘4’ => ‘Williams’,
‘5’ => ‘Jones’,
‘6’ => ‘Brown’,
‘7’ => ‘Davis’,
‘8’ => ‘Miller’,
‘9’ => ‘Wilson’,
‘10’ => ‘Moore’,
‘11’ => ‘Taylor’,
‘12’ => ‘Anderson’,
‘13’ => ‘Thomas’,
‘14’ => ‘Jackson’,
‘15’ => ‘White’,
‘16’ => ‘Harris’,
‘17’ => ‘Martin’,
‘18’ => ‘Thompson’,
‘19’ => ‘Garcia’,
‘20’ => ‘Martinez’,
‘21’ => ‘Robinson’,
‘22’ => ‘Clark’,
‘23’ => ‘Rodriguez’,
‘24’ => ‘Lewis’,
‘25’ => ‘Lee’,
‘26’ => ‘Walker’,
‘27’ => ‘Hall’,
‘28’ => ‘Allen’,
‘29’ => ‘Young’,
‘30’ => ‘Hernandez’,
‘31’ => ‘King’,
‘32’ => ‘Wright’,
‘33’ => ‘Lopez’,
‘34’ => ‘Hill’,
‘35’ => ‘Scott’,
‘36’ => ‘Green’,
‘37’ => ‘Adams’,
‘38’ => ‘Baker’,
‘39’ => ‘Gonzalez’,
‘40’ => ‘Nelson’,
‘41’ => ‘Carter’,
‘42’ => ‘Mitchell’,
‘43’ => ‘Perez’,
‘44’ => ‘Avery’,
‘45’ => ‘Hebert’,
‘46’ => ‘Whitney’,
‘47’ => ‘Waller’,
‘48’ => ‘Peck’,
‘49’ => ‘Jacobson’,
‘50’ => ‘Irwin’);

//Random Date
$year = array(‘1’ =>‘2010’,
‘2’ =>‘2009’);
$month = array(‘1’ =>‘01’,
‘2’ =>‘02’,
‘3’ =>‘03’,
‘4’ =>‘04’,
‘5’ =>‘05’,
‘6’ =>‘06’,
‘7’ =>‘07’,
‘8’ =>‘08’,
‘9’ =>‘09’,
‘10’ =>‘10’,
‘11’ =>‘11’,
‘12’ =>‘12’);
$day = array(‘1’ =>‘01’,
‘2’ =>‘02’,
‘3’ =>‘03’,
‘4’ =>‘04’,
‘5’ =>‘05’,
‘6’ =>‘06’,
‘7’ =>‘07’,
‘8’ =>‘08’,
‘9’ =>‘09’,
‘10’ =>‘10’,
‘11’ =>‘11’,
‘12’ =>‘12’,
‘13’ =>‘13’,
‘14’ =>‘14’,
‘15’ =>‘15’,
‘16’ =>‘16’,
‘17’ =>‘17’,
‘18’ =>‘18’,
‘19’ =>‘19’,
‘20’ =>‘20’,
‘21’ =>‘21’,
‘22’ =>‘22’,
‘23’ =>‘23’,
‘24’ =>‘24’,
‘25’ =>‘25’,
‘26’ =>‘26’,
‘27’ =>‘27’,
‘28’ =>‘28’);

//insert new data into the reviews table
$query = <<<ENDSQL
INSERT INTO reviews
(review_host_id, review_date, reviewer_name, review_comment, review_rating)
VALUES
(1, “$year[rand(1, 3)]-$month[rand(1, 12)]-$day[rand(1, 28)]”, “$firstname[rand(1, 50)] $lastname[rand(1, 50)]”),[/php]

Any ideas?

Sponsor our Newsletter | Privacy Policy | Terms of Service