-3

I would like my input fields to be displayed with an echo statement. I receive the following error instead "Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/content/76/12797276/html/stu05/homework one/student.php on line 8"

any ideas of what's going on? here is my code

<form action = student.php method="get">
First name:
<input type=text name=fname><br><br>
Last name:
<input type=text name=lname><br><br>
Student ID:
<input type=text name=studentid><br><br>

Gender: 
<select name="gender">
<option  value="male">Male</option>
<option  value="female">Female</option>
</select><br><br>

Semester: 
<select name="semester">
<option  value="winter">Winter</option>
<option  value="spring">Spring</option>
<option  value="summer">Summer</option>
<option  value="fall">Fall</option>


</select><br><br>
<input type=submit value="Click">

</form>

and the php code

<?
$name_first = $_GET['fname'];
$name_last = $_GET['lname'];
$student_ID = $_GET['studentid'];
$gender_select = $_GET['gender'];
$semester_select = $_GET['semester'];

echo "User ".$name_first" ".$name_last<br>
"Student ID: ".$student_ID<br>
"is a ".$gender_select " and has enrolled in the ".$semester_select "semester    ";

?>
D0uble0
  • 175
  • 1
  • 2
  • 12

1 Answers1

0

This is not valid:

echo "User ".$name_first" ".$name_last<br>

Give this way:

echo "User ".$name_first." ".$name_last."<br>

You have forgotten the concatenation. Your final code should be:

echo "User ".$name_first." ".$name_last."<br>Student ID: ".$student_ID."<br>is a ".$gender_select." and has enrolled in the ".$semester_select."semester    ";

Every code, you have left the second ..

Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252