Jump to content

ECHO error - Cannot identify the problem


jhc1982

Recommended Posts

Hi Guys,

 

I keep getting the following error:

 

Parse error: syntax error, unexpected T_ECHO in /Applications/XAMPP/xamppfiles/htdocs/pet/petCatalog1.php on line 51

 

I have copied the code from a tutorial and cannot for the life of me work out what the problem is with line 51????

 

I have attached the file and pasted the code below. The real problem line is:

 

 

echo "<tr><td valign='top' width='15%' style='font-weight: bold; font-size: 1.2em'\n"

 

The full code is attached - btw, inserting the ">" does not help to fix it!!

 

<?php

/* Programme: PetCatalog.php

* Desc: Lists all pet categories with radio buttons

*/

?>

 

<html>

<head>

<title>Select a Pet Category</title>

</head>

<body>

 

<?php

/* Database login info - Move to an Include

*/

 

$host="localhost";

$user="root";

$passwd="";

$dbname="information_schema";

 

/* Establishes a connection with the databse

*/

 

$cxn = mysqli_connect ($host, $user, $passwd, $dbname)

or die ("Could not connect to the database JAMIE!");

 

/* SQL Query to select all categories of pet from the petType column in the pet table

*/

 

$query = "SELECT * FROM PetCatalog.petType ORDER BY petType";

$result = mysqli_query($cxn,$query)

or die ("Unable to connect to the database JAMIE");

 

/* Echo of H1 & H2 above the pet table

*/

 

echo "<div style='margin-left: .lin'>\n

<h1 style='text-align: center'>Pet Catalogue</h1>\n

<h2 style='text-align: center'>The following categories of pets are now available</h2>\n";

 

/* Create form to diplay pet categories

*/

 

echo "<form action='ShowPets.php' method='POST'>\n";

echo "<table cellpadding='5' border='1'>";

$counter=1;

while ($row = mysqli_fetch_assoc($result))

{

extract ($row)

echo "<tr><td valign='top' width='15%' style='font-weight: bold; font-size: 1.2em'\n"

echo "<input type='radio' name='interest' value='$petType'\n";

if( $counter == 1 )

{

echo "checked='checked'";

}

echo ">$petType</td>";

echo "<td>$typeDescription</td></tr>";

$counter++;

}

echo "</table>";

echo "<p>input type='submit' value='Select Pet Type'>

</form></p>\n";

 

?>

</body>

</html>

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/222126-echo-error-cannot-identify-the-problem/
Share on other sites

Thanks guys,

 

It is a bit frustrating! This is the second time that copying the book word for word (including typos) has let me down. Next time I think I will take the concept and this about how to put it together myself.

 

Thanks again!

Jamie

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.