Why is this PHP script throwing errors?

Posted on 2014-08-28
Last Modified: 2014-08-28
Why it this PHP script throwing errors?

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

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

- Yvan
Question by:egoselfaxis
    LVL 11

    Accepted Solution

    This is not error, this is warning. Your program is probably working fine.
    You can either specify date formattign string as described here:

    Or supress PHP warnings by using
    at the beginning of your php script.
    LVL 58

    Expert Comment

    I'm guessing, based on your code, where you have you date() you should be using

    Author Closing Comment

    Right you are -- thank you very much!

    - Yvan
    LVL 11

    Expert Comment

    by:Radek Baranowski
    nice one :) good luck.
    LVL 58

    Expert Comment

    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

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
    Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
    This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now