I'm new to PHP and have been studying for 2 weeks as part of one of my university modules. I have a good understanding of HTML but PHP is a completely new concept to me. My only previous knowledge in a programming language is an introductory level in Java. I've been struggling with a couple of errors for a few hours now and have searched through several websites include W3Schools and PHP.net for solutions but have had no luck as of yet.

My operating system is OSX 10.6.8
I am using XAMPP


Error 1
My first error displays as
Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /Applications/XAMPP/xamppfiles/htdocs/taskone/extension.php on line 9
My HTML
Code:
<html>
<body>

<form action="extension.php" method="post">
Name: <input type="text" name="fname"><br />
Surname: <input type="text" name="sname"><br />
Age: <input type="text" name="age"><br />
Number of loops:<select name="loops">
<option value="1" selected="selected">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select><br/>
<input type="submit">
</form>

</body>
</html>
My PHP
PHP Code:
<html>
<body>

<?php

$x 
$_REQUEST["loops"];
while (
$_REQUEST 0)
{
echo 
"Welcome " $_POST["fname"] . $_POST["sname"] . 
" You are " $_POST["age"" years old.";
$x--;
}

?>

</body>
The purpose of the drop down box is for the user to decide how many times they wish for the Name, Surname and Age to be printed. Prior to the above error, I was receiving a different error for the while loop on line 7 and am not entirely sure if or how I have solved that.

Error 2
The second error that is displaying says
Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0

Fatal error: Unknown: Failed opening required '/Applications/XAMPP/xamppfiles/htdocs/tasktwo/students1.php' (include_path='.:/Applications/XAMPP/xamppfiles/lib/php:/Applications/XAMPP/xamppfiles/lib/php/pear') in Unknown on line 0
This error is being caused by a database I have created in MySQL named students1. The database contains one table named students1 and in this table there are three entries. I have been given the following two PHP files by my lecturer and told to access it by http://localhost/students1.php and when this is entered is the point at which the error is displayed.

students1.php
PHP Code:
<html>

<head>Getting data from a MySQL database using PHP</head>

<body>

<p>This php powered page will print out the contents of a table in a database

<?php

// This part of the code sets up our database connection
// The credentials are in the file dbinfo.inc.php
// Once the connection is made, we make the query

include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);
@
mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM table1";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
?>

<table>
<tr> 
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>


<?php

// This bit of the code sets up a loop and gets the 
// results from the query row at a time

$i=0;
while (
$i $num) {
$firstname=mysql_result($result,$i,"firstname");
$lastname=mysql_result($result,$i,"lastname");
$age=mysql_result($result,$i,"age");
?>

<tr>
<td><?php echo "$firstname?></td> 
<td><?php echo "$lastname?></td>
<td><?php echo "$age?></td>
</tr>

<?php
$i
++;

echo 
"</table>";
?>

</body>
</html>
dbinfo.inc.php
PHP Code:
<?php
$username
="root";
$password="";
$database="students1";
?>


I'm new to the forum so am not sure if I've posted correctly, I have checked your forums sticky posts and the FAQs and tried to keep by them. If any extra info is required please let me know.

Any help is much appreciated.