Why is this PHP script throwing errors?

Why it this PHP script throwing errors?

<select name="q2" id="q2" required>
<option value="">---- Select One ----</option>
<?php
	$start_year = date('Y')-100;
	$end_year   = $start_year+100;						
	for($i=$start_year; $i<=$end_year; $i++) {				
		if ($_SESSION['q2'] == $i.date()) {					
			echo '<option value='.$i.date().' selected="selected">'.$i.date().'</option>';
		} else {				
			echo '<option value='.$i.date().'>'.$i.date().'</option>';				   
	   }				   
	}
?>
</select>

Open in new window


When I view the underlying generated source code for this select dropdown,  I see the following error message for each iteration in the loop.  How can I modify my PHP script to eliminate it?

Warning:  date() expects at least 1 parameter, 0 given in /home/ideasdes/public_html/sts/index.html on line 1253

Thanks!
- Yvan
egoselfaxisAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Radek BaranowskiFull-stack Java DeveloperCommented:
This is not error, this is warning. Your program is probably working fine.
You can either specify date formattign string as described here: http://www.w3schools.com/php/func_date_date.asp

Or supress PHP warnings by using
error_reporting(1);
at the beginning of your php script.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GaryCommented:
I'm guessing, based on your code, where you have you date() you should be using
date('Y')
0
egoselfaxisAuthor Commented:
Right you are -- thank you very much!

- Yvan
0
Radek BaranowskiFull-stack Java DeveloperCommented:
nice one :) good luck.
0
GaryCommented:
Warnings are there for a reason, you don't just suppress them and pretend like they don't exists - the code is wrong and needs to be fixed
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.