Problem with arrays

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
adamski
Forum Newbie
Posts: 3
Joined: Mon Feb 01, 2010 3:40 pm

Problem with arrays

Post by adamski »

ok I am sure this is a simple problem and some one will help me.
This is piece of my kode :

/*this is line number 15*/ $months = array ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');

when I preview in my browser an error shows up : Parse error: parse error in c:\calendar.php on line 15
Problem is that code is right what could be a cause ?
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

Re: Problem with arrays

Post by klevis miho »

Paste more code
adamski
Forum Newbie
Posts: 3
Joined: Mon Feb 01, 2010 3:40 pm

Re: Problem with arrays

Post by adamski »

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/ TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/ xhtml” xml:lang=”en” lang=”en”>
<head>
<meta http-equiv=”content-type” content=”text/html; charset=iso-8859-1” />
<title>Nauka PHP</title>
</head>
<body>
<form action=”calendar.php” method=”post”>
<?php # Script 2.6 - calendar.php

// This script makes three pull-down
menus
// for an HTML form: months, days, years
// Make the months array:
$months = array (1 => 'January',
'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September',
'October', 'November', 'December');

// Make the days and years arrays:
$days = range (1, 31);
$years = range (2008, 2018);

// Make the months pull-down menu:
echo '<select name=”month”>';
foreach ($months as $key => $value) {
echo "<option value=\"$key\">$value
</option>\n";
}
echo '</select>';
// Make the days pull-down menu:
echo '<select name="day">';
foreach ($days as $value) {
echo "<option value=\"$value\">$value
</option>\n";
}
echo '</select>';

// Make the years pull-down menu:
echo '<select name="year">';
foreach ($years as $value) {
echo "<option value=\"$value\">$value
</option>\n";
}
echo '</select>';

?>
</form>
</body>
</html>
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Problem with arrays

Post by social_experiment »

Code: Select all

<?php
// This script makes three pull-down
menus # <--- comment this
// for an HTML form: months, days, years
// Make the months array:
$months = array (1 => 'January',
'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September',
'October', 'November', 'December');?>
Im guessing the problem is with the word "menus" not being commented. For multi-line comments it's best to use /* */
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
adamski
Forum Newbie
Posts: 3
Joined: Mon Feb 01, 2010 3:40 pm

Re: Problem with arrays

Post by adamski »

hah thanks mate thats it :]
Post Reply