SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2008
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Having trouble making my page valadite.

    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.

    Code:
    <!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>&nbsp;</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>&nbsp;</p>
    <h2>Volunteer Now!</h2>
        <p>&nbsp;</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");
    ?>

  2. #2
    SitePoint Guru alecrust's Avatar
    Join Date
    Jun 2007
    Location
    London, UK
    Posts
    728
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, it doesn't work like that I'm afraid

    You don't put PHP into the markup validator. Upload the page, view it in the site and you will notice that if you view the source in your web browser you will not be able to see any of the PHP. This code you're now seeing is what needs to be validated.

    The W3 Markup Validator does not validate PHP code. To quote the site:

    Quote Originally Posted by W3c Markup Validation Service
    This validator checks the markup validity of Web documents in HTML, XHTML, SMIL, MathML
    Honda Civic Forum - UK Civic Forum
    Web Host Reviews - Independent, honest host reviews
    My Portfolio - Simplicity is the ultimate sophistication

  3. #3
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If the page is reachable online, just use the Validate by URI option and point the validator to your page. If not, you need to do what Alec said and copy/paste the generated markup.
    Birnam wood is come to Dunsinane

  4. #4
    SitePoint Guru alecrust's Avatar
    Join Date
    Jun 2007
    Location
    London, UK
    Posts
    728
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's just the phrase I was looking for: generated markup.
    Honda Civic Forum - UK Civic Forum
    Web Host Reviews - Independent, honest host reviews
    My Portfolio - Simplicity is the ultimate sophistication

  5. #5
    SitePoint Enthusiast
    Join Date
    Apr 2008
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OMG lol what a wast of like 3 hours

    http://validator.w3.org/check?uri=ht...Inline&group=0

    lol thanks so much for the help m8!

    I have another page that is stumping me but i don't want to make it public. If you dont mind taking a look at it i'll send you a temp user name and password via pm.

  6. #6
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by alecrust View Post
    That's just the phrase I was looking for: generated markup.
    Sorry mate, I borrowed it and forgot to put it back.
    Birnam wood is come to Dunsinane

  7. #7
    SitePoint Zealot evilunix's Avatar
    Join Date
    Jun 2008
    Location
    York, UK.
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quick tip for firefox users: Ctrl + Shift + H sends the open page to the W3C validator...

  8. #8
    SitePoint Enthusiast
    Join Date
    Apr 2008
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do any of you mind looking at my code?

  9. #9
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Snot View Post
    Do any of you mind looking at my code?
    You really need to post your output code (the HTML) or give a link to get help, posting PHP to try and solve a validation problem makes people nuts. If the code isn't live bring it up in a browser on your development machine, then view source and copy and paste that code here.

  10. #10
    SitePoint Enthusiast
    Join Date
    Apr 2008
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm sorry i must have be making any sense.

    let me show you what I mean

    http://www.tarantuladatabase.com/admin/new.php

    all I did was take new.html and rename it to new.php so I can add some php code because you have have html in a php file but you can't have php and an html file.

  11. #11
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Snot View Post
    I'm sorry i must have be making any sense.

    let me show you what I mean

    http://www.tarantuladatabase.com/admin/new.php

    all I did was take new.html and rename it to new.php so I can add some php code because you have have html in a php file but you can't have php and an html file.
    That link requires a log in ... and still, we need to see the final output of the page to help with validation.

  12. #12
    SitePoint Enthusiast
    Join Date
    Apr 2008
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Snot View Post
    I have another page that is stumping me but i don't want to make it public. If you dont mind taking a look at it i'll send you a temp user name and password via pm.
    Now you are confusing me too lol! I know it requires a login thats why i'm trying to do all of this instead of just posing the link.

    I don't mind giving a temp username and password to someone the a high post count but I dont want to post it in the forums for everyone to see.

    So if you are interested in helping me just say so and i'll pm it to you. Then you can see how it looks in the w3c validation system

  13. #13
    SitePoint Enthusiast
    Join Date
    Apr 2008
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply but I figured it out.

    I had tot replace a few of the & symbols with &amp;

    The & character has special meaning. It says "what comes next is a character entity". Since I had &id the browser/validator was expecting a character entity but there is none called &id.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •