Jump to content

Could my php be making my html invalid?


NovaArgon

Recommended Posts

I am having trouble getting this page to validate. Would any of you mind taking a look at it and giving me some very very basic advice?

I am very new to php code so i'm easily confused lol.

 

I have just been pasting my code into here

 

http://validator.w3.org/#validate_by_input

 

Alot of the errors look like they are from the php tags and the body and html tags are in the footer so thats why they are showing up.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Tarantula Database Search Results</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <meta name="description" content="Here you will find everything you ever wanted to know about Tarantulas. Simply fill out the search form and begin seaching our estensive tarantula database." />
  <meta name="keywords" content="Tarantula, Tarantula Database, Tarantula Search, Tarantula Forum" />
  <meta name="robots" content="all" />
  <meta name="author" content="" />
  <link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" />
</head>

<body>
<div id="container">

<?php
include('../../include/header.php');
include('connect.php');
?>
  
  <div id="content">
    <h3>Tarantula Database Search Results!</h3>
    <p> </p>
<?php

if(empty($_POST['habitat']) && empty($_POST['humidity']) && empty($_POST['speed']) && empty($_POST['size']) && empty($_POST['location']) && empty($_POST['aggression'])){
echo "You did not tell us what to search for!<br><br><br>";
}else{// if there is something to search with....


if(isset($_POST['habitat'])){
$habitat = mysql_real_escape_string(trim($_POST['habitat']));
}

if(isset($_POST['humidity'])){
$humidity = mysql_real_escape_string(trim($_POST['humidity']));
}

if(isset($_POST['speed'])){
$speed = mysql_real_escape_string(trim($_POST['speed']));
}
if(isset($_POST['size'])){
$size = mysql_real_escape_string(trim($_POST['size']));
}
if(isset($_POST['location'])){
$location = mysql_real_escape_string(trim($_POST['location']));
}
if(isset($_POST['aggression'])){
$aggression = mysql_real_escape_string(trim($_POST['aggression']));
}



$where = '';
if(isset($habitat)) {
$where? $where .= " AND habitat = '$habitat' " : $where = " habitat = '$habitat' ";
};
if(isset($humidity)) {
$where? $where .= " AND humidity = '$humidity' " : $where = " humidity = 'humidity' ";
}
if(isset($speed)) {
$where? $where .= " AND speed = '$speed' " : $where = " speed = '$speed' ";
}
if(isset($size)) {
$where? $where .= " AND size = '$size' " : $where = " size= '$size' ";
}
if(isset($location)) {
$where? $where .= " AND location = '$location' " : $where = " location = '$location' ";
}
if(isset($aggression)) {
$where? $where .= " AND aggression = '$aggression' " : $where = " aggression = '$aggression' ";
}


$result = mysql_query("SELECT * FROM `common_traits` WHERE $where AND `approved`='0'") or die(mysql_error());
$count = mysql_num_rows($result);


if($count == 0){
echo "There were no records found in the database with the traits you wanted.<br>";
echo "You may also <a href='submit.php'>submit a tarantula to our database</a>";
echo " if you know of the tarantula you are searching for.<br>";
echo "You searched our records with the following requirements<br>$where";
}else{
echo "You searched our records with the following requirements<br>$where";
echo "<br>There is $count record(s) found with those requirements" ;
}



function bold($handle, $post, $data){// function to bold the searched terms

if(!empty($data)){// if something was found in the database

if($post == $data){// if the searched term (post) is the same as the column of data in databse, highlight it
echo "<b>";
echo $handle;
echo ": ";
echo $data;
echo "</b>";

}else{// show as regular
echo $handle;
echo ": ";
echo $data;
} 

}else{// if he databse entry was emtpy

echo $handle;
echo ": ";
echo "<i>empty</i>";
}
echo "<br>";
}

echo "<table><tr>";
while($row = mysql_fetch_array($result)){
echo "<br><br><br>";
bold('Genus', $genus, $row['genus']);
bold('Species', $empty, $row['species']);
bold('Habitat', $habitat, $row['habitat']);
bold('Size', $size, $row['size']);
bold('Speed', $speed, $row['speed']);
bold('Location', $location, $row['location']);
bold('Humidity', $humidity, $row['humidity']);
bold('Aggression', $aggression, $row['aggression']);
}

echo "</tr></table>";
}// end of else (located on line 28)
?>

<p> </p>
<h2>Volunteer Now!</h2>
    <p> </p>
    <p>Tarantula Database is currently looking for volunteers to  help with our construction process. If you have any skills in PHP, MYSQL, or general web design please <a href="contact.html">contact us</a> for more information.</p>
      </div>
      
      </div>
  <?
include("../../include/footer.php");
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.