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

<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>
<input type="submit">

PHP Code:


while (
"Welcome " $_POST["fname"] . $_POST["sname"] . 
" You are " $_POST["age"" years old.";


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.

PHP Code:

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


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


// 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

mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM table1";



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

while (
$i $num) {

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



PHP Code:

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.