Błędy validacji PHP i </thead></tbody

0

Witam mam problem z validacja kodu php. Co jest nie tak z tym PHP?

<!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="pl" lang="pl">

<p>Login**: <input type="text" name="login" id="l" value="<?php print $l; ?>" size="30" maxlength="30" /><br /></p> 

Wynik walidacji to:
[kod=html]…ype="text" name="login" id="l" value="<?php print $l; ?>" size="30" maxlength=…[/kod]

Opis błedu:

[quote]Line 98, Column 59: character "<" is the first character of a delimiter but
This message may appear in several cases:
•You tried to include the "<" character in your page: you should escape it as "<"
•You used an unescaped ampersand "&": this may be valid in some contexts, but it is recommended to use "&", which is always safe.
•Another possibility is that you forgot to close quotes in a previous tag.[/quote]

to zaznaczony na czerwono "<" przed <?php.

i drugi problem z znacznikiem i

<table border="1"><tbody>
<thead>
<tr><th>Login</th><th>Uprawnienia</th><th>Imie</th><th>Nazwisko</th><th>Telelefon</th></tr>

<?php
$db = new PDO('mysql:host=localhost;dbname=kino', klient, klient);
$sql="SELECT  login, upr, imie, nazwisko, tel  FROM klienci WHERE login='$login' ";
$res=$db->query($sql);
while($row = $res->fetch())
  {
	print '<td><a href="edycja_kont.php?akcja=edytuj">'.$row['login'].'</td>';
  print '<td>'.$row['upr'].'</td>';
	print '<td>'.$row['imie'].'</td>';
  print '<td>'.$row['nazwisko'].'</td>';
  print '<td>'.$row['tel'].'</td></tr>'.PHP_EOL;
}
?>
</thead></tbody></table>` `

Line 55, Column 7: document type does not allow element "thead" here<thead>

The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed). 

One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).[/quote] 

[quote]Line 75, Column 16: end tag for "tbody" which is not finished</thead></tbody></table>

Most likely, you nested tags and closed them in the wrong order. For example <p><em>...</p> is not acceptable, as <em> must be closed before <p>. Acceptable nesting is: <p><em>...</em></p> 

Another possibility is that you used an element which requires a child element that you did not include. Hence the parent element is "not finished", not complete. For instance, in HTML the <head> element must contain a <title> child element, lists require appropriate list items (<ul> and <ol> require <li>; <dl> requires <dt> and <dd>), and so on


Wydaje mi się że znaczniki <tbody> <thead> są w dobrej kolejności pozamykane, są z małej litery i wszystkie są zamknięte "/".

O co biega???
0

Masz thead wewnątrz tbody. http://www.w3schools.com/tags/tag_tbody.asp

0

Line 98, Column 59: character "<" is the first character of a delimiter but

Ten parser nie bierze pod uwagę, że wewnątrz znajduje się kod PHP, stąd błąd.

Wydaje mi się że znaczniki są w dobrej kolejności pozamykane

Pozamykane to może i dobrze, lecz nie są w dobrej kolejności as-is.
http://www.poradnik-webmastera.com/polecenia/html/znaczniki/znacznik_thead.html
Przyjrzyj się umieszczonemu tam przykładowi.

0

Faktycznie z tym tabelami namieszałem.

A co do tego błędu ...Patryk27 php nie rozumiem co masz na myśli. Masz może jakiś pomyśł jak to rozwiązać?

Patryk27 napisał(a):

Line 98, Column 59: character "<" is the first character of a delimiter but

Ten parser nie bierze pod uwagę, że wewnątrz znajduje się kod PHP, stąd błąd.

Pokazuje mi jeszcze jedno ostrzeżenie co do utf-8 Mimo, że w nagłówku mam zdeklarowane utf-8. O co biega???

<!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="pl" lang="pl">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<link rel="Stylesheet" type="text/css" href="style.css" /> 

Using Direct Input mode: UTF-8 character encoding assumed

Unlike the “by URI” and “by File Upload” modes, the “Direct Input” mode of the validator provides validated content in the form of characters pasted or typed in the validator's form field. This will automatically make the data UTF-8, and therefore the validator does not need to determine the character encoding of your document, and will ignore any charset information specified.

If you notice a discrepancy in detected character encoding between the “Direct Input” mode and other validator modes, this is likely to be the reason. It is neither a bug in the validator, nor in your document.

0

Po prostu o ile dobrze pamiętam, to walidator nie zwraca uwagi na fakt, że wewnątrz tego: value="<?php print $l; ?>" size="30 znajduje się kod PHP (<?php print $l; ?>) i wymaga, aby zamienić to na:
&lt;?php&nbsp;print... - po prostu zignoruj ten komunikat.

0

Pokazuje mi jeszcze jedno ostrzeżenie co do utf-8 Mimo, że w nagłówku mam zdeklarowane utf-8. O co biega???

Jeżeli robisz walidację wklejając kod w Direct Input to on zawsze przyjmuje kodowanie jako utf-8 (prawdziwe kodowanie, a to, co ty zadeklarowałeś to dwie różne rzeczy) - jeżeli wybierzesz by File Upload, albo by URI - to ostrzeżenia nie będzie.

ps. ucz się angielskiego

0

Wielkie dzięki za pomoc i porady.

Został mi jeszcze jeden bład do wychwycenia i nie widze go. Na moje oko pierwsza tabela jest dobrze zamknięta w dobrej kolejeności.

<table class="ramka"><tbody>
<?php
for ($y=0; $y<=9; $y++) {
	echo "<tr> \n";
	for ($x=1; $x<=10; $x++) {
	$sql="SELECT opis FROM seans WHERE krzeslo=($y*10+$x)";
  $wyn=$db->query($sql)->fetch();
  if(empty($wyn['opis']))
		print '  <td class="wolne">';
		else
		print '  <td class="rezerwacja">';
		//echo $y*10+$x;
		print '<a href="?krzeslo='.($y*10+$x).'">'.($y*10+$x).'</a>';
		
		print '</td>'.PHP_EOL;
		
	}
	echo "</tr> \n";
}

?>
</tbody></table>

<table>
<tbody>
  <tr>
    <td class="wolne"></td><td> - Miejsce wolne</td>
		</tr>
		<tr>
		<td class="rezerwacja"></td><td> -  Miejsce zajęte </td>
  </tr>
</tbody>
</table>

<quote></tbody></table>

Most likely, you nested tags and closed them in the wrong order. For example

...

is not acceptable, as must be closed before

. Acceptable nesting is:

...

</p>

Another possibility is that you used an element which requires a child element that you did not include. Hence the parent element is "not finished", not complete. For instance, in HTML the <head> element must contain a <title> child element, lists require appropriate list items (

and require ; <dl> requires <dt> and <dd>), and so on.</qoute></p>
0

Przecież napisał Ci walidator. Jest zamknięta w dobrej kolejności, ale patrz dalej:

</tbody></table>

Most likely, you nested tags and closed them in the wrong order. For example

...

is not acceptable, as must be closed before

. Acceptable nesting is:

...

</p>

Another possibility is that you used an element which requires a child element that you did not include. Hence the parent element is "not finished", not complete. For instance, in HTML the <head> element must contain a <title> child element, lists require appropriate list items (

and <ol> require
; <dl> requires <dt> and <dd>), and so on

Według w3fools:

Note: The element must have one or more tags inside.

An HTML table consists of the

one or more , , and elements.</p>

PS. Ty <td> generujesz dynamicznie więc walidator nie może o nich wiedzieć.

0

Ok dzieki :)

1 użytkowników online, w tym zalogowanych: 0, gości: 1