<select> with PHP users

I’m getting an

Parse error: syntax error, unexpected ‘’ (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)
ERROR when I’m using the code directly below.

$query = dbConnect()-&gt;prepare("SELECT `firstname`, `lastname` FROM `loaders` ");

foreach($query-&gt;fetchAll(PDO::FETCH_ASSOC) as $rows){

	echo "&lt;option value=\\"$rows['firstname']\\"&gt;", $rows['firstname'], ' ', $rows['lastname'], '&lt;/option&gt;';


But when I run the code:

echo '&lt;option value="firstname"&gt;', $rows['firstname'], ' ', $rows['lastname'], '&lt;/option&gt;';

It displays all the users, but doesn’t submit the information into the database, into process.php


	if(isset($_POST['firstname'], $_POST['lastname'], $_POST['notes'], $_POST['time'])){
		require 'core/connect.php';

		$query = dbConnect()-&gt;prepare("INSERT INTO `loaders` (firstname, lastname, notes, time) VALUES (:firstname, :lastname, :notes, :time)");
		$query-&gt;bindParam(':firstname', $_POST['firstname']);
		$query-&gt;bindParam(':lastname', $_POST['lastname']);
		$query-&gt;bindParam(':notes', $_POST['notes']);
		$query-&gt;bindParam(':time', $_POST['time']);
			header('Location: index.php');
		} else {
			echo 'There has been an error';

If you’re going to use a variable in double quotes you should wrap it in curly braces. In the case of using arrays as you are, it is required.

"<option value=\\"$rows['firstname']\\">"

would become

"<option value=\\"{$rows['firstname']}\\">"

A simpler alternative:

echo '&lt;option value="'.$rows['firstname'].'"&gt;'.$rows['firstname']. ' '. $rows['lastname']. '&lt;/option&gt;';