Hi guys… I’ve been getting this error message:
Parse error: parse error, unexpected $ … on line # and the line number is the last line of my coding!
This is probably the toughest, meatiest page for my school final project. I finish this and I will receive my UW Certificate in Web Technology!
There’s probably one semicolon or some tiny yet crucial detail I’ve missed somewhere. I think I have the concept pretty much in hand… but GARGH!!
Thanks for checking out my issue!
Don
[code]<?php # Pet Satisfaction Survey ITA343 Final Project addpet.php
// This is the add pet data page for the site.
// Set the page title and include the HTML header.
$page_title = ‘Add Pet Data’;
include_once (’./includes/header.html’);
// since these following values are just values collected from radio buttons or a pulldown
// the liklihood of them getting compromised is quite low. Therefore, no need to encode or escape_data-ize.
$animal = $_POST[‘animal’];
$health_sat = $_POST[‘health_sat’];
$clean_sat = $_POST[‘clean_sat’];
$afford_sat = $_POST[‘afford_sat’];
$enjoy_sat = $_POST[‘enjoy_sat’];
$care_sat = $_POST[‘care_sat’];
$repeat_sat = $_POST[‘repeat_sat’];
if (isset($_POST[‘submitted’])) { // Handle the form.
require_once ('./includes/db_connect.php'); // Connect to the database.
// Check for a pet name.
if (eregi ('^[[:alpha:].' -]{2,15}$', stripslashes(trim($_POST['pet_name'])))) {
$petname = escape_data($_POST['pet_name']);
} else {
$petname = FALSE;
echo '<p><font color="red" size="+1">Please enter your pets name!</font></p>';
}
// Check for pet's years owned
if (is_numeric($_POST['years_owned'])) {
$yo = escape_data($_POST['years_owned']);
} else {
$yo = FALSE;
echo '<p>Please enter years owned for this pet</p>';
}
// Check for pet's age
if (is_numeric($_POST['age'])) {
$age = escape_data($_POST['age']);
} else {
$age = FALSE;
echo '<p>Please enter pets age less than 99 years!</p>';
}
if ($petname && $yo && $age) { // If everything's OK.
// Add the pet data.
$query = "INSERT INTO PETS (pet_name, animal, years_owned, age, health_sat, clean_sat, afford_sat, enjoy_sat, care_sat, repeat_sat) VALUES ('$petname', '$animal', '$yo', '$age', '$health_sat', '$clean_sat', '$afford_sat', '$enjoy_sat', '$care_sat', '$repeat_sat')";
$result = mysql_query ($query) or trigger_error("Query: $queryn<br />MySQL Error: " . mysql_error());
if (mysql_affected_rows() == 1) { // If it ran OK.
} else { // If it did not run OK.
// If one of the data tests failed.
echo '<p><font color="red" size="+1">Please try again.</font></p>';
}
mysql_close(); // Close the database connection.
} // End of the main Submit conditional.
?>
Pet Information
Pet's Name:
Animal: <php // This function makes a pull-down menus for some animals. // Adding new animal types is easily done here, by just adding to the array below. // In case a user wants to register their sloth or platypus...
function animal_pulldown() {
// Make the animals array.
$animals = array (1 => 'dog', 'cat', 'ferret', 'bird', 'horse', 'pony', 'small mammal', 'pig', 'fish', 'ostrich', 'alpaca', 'bear', 'lion', 'turtle', 'frog', 'snake', 'lizard', 'insect', 'monkey');
// Make the animal pull-down menu.
echo '<select name="animal">';
foreach ($animals as $key => $value) {
echo "<option value="$key">$value</option>n";
}
echo '</select>';
?>
Years Owned:
Age (or highest age reached) (you may indicate with decimals, ie 5.5, if you wish):
// This is where the users opinions of their satisfaction of each pet is collected
We will now ask you to RATE your satisfaction of this pet you owned. On a Scale from 1 to 5 (with 1 indicating the lowest satisfaction, and 5 indicating the highest satisfaction) please tell us your satisfaction for each topic:
Your Satisfaction with this particular pet's Overall Health: 1 2 3 4 5
Your Satisfaction with this particular pet's Overall Cleanliness: 1
2 3 4 5Your Satisfaction with this particular pet's Overall Affordability: 1
2 3 4 5Your rating of Enjoyment you had with this particular pet: 1
2 3 4 5Your Satisfaction with this particular pet's Overall Ease of Care: 1
2 3 4 5All things considered, would you own this same type of pet again?: YES
No<div align="center"><input type="submit" name="submit" value="Add" /></div>
<input type="hidden" name="submitted" value="TRUE" />
<?php
include ('./includes/footer.html');
?>[/code]