Jump to content

doctype and meta tags in php file


Pain

Recommended Posts

Hello again:]

 

I am wondering where should i put valid doctype

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

and meta tags

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

 

in a php file like this.

 

<?php

session_start(); // Session starts here
if(!isset($_SESSION['username'])) // If there is no session then...
{
    die ("<div align='center'><img src='images/LOGINKITTEN.jpg'/><br /><a href='index.php'><img src='images/Login.jpg'/></a></div>"); // ...Die!
} 

$id = $_GET['id'];

?>
<html>
<head>

<link rel="stylesheet" type="text/css" href="jamcss.css" />

</head>
<body>

<img src="images/jamspace.jpg" />
<div id="jamcontainer">
<b><a href="main.php">Home</a>  ||  <a href="members.php">Members</a>  ||  <a href="jams.php">Jams</a>  ||  <a href="uploadjamform.php">Upload Jam</a>  ||  <a href="myprofile.php">My profile</a>  ||  <a href="about.php">About</a>  ||  <a href="adminindex.php">Moderators</a> ||  <a href="logout.php">Logout</a></b>             You are logged in as <?php echo $_SESSION['username']; ?>
<br /><br />

<?php

$connection = mysql_connect("lol.com", "loldb", "lol00") or die ("Could not connect");
mysql_select_db("loldb", $connection) or die("Could not connect");

// mysql query to get the username
$query = mysql_query("SELECT * FROM news ORDER BY id DESC");
$numrows = mysql_num_rows($query);



if ($numrows!=0)
{
// fetching data from the database to variable
while ($row = mysql_fetch_assoc($query))
{
	$title = $row['title'];
	$post_owner = $row['post_owner'];
	$post = $row['post'];
	echo "<b>" . $title . "</b><br />";
	echo "Posted by <b>" . $post_owner . "</b><br /><br />";
	echo $post . "<hr></hr><br /><br />";
}
}

?>
</div>
</body>
</html>

Link to comment
Share on other sites

I think you're good to just place it directly below your first php closing tag mate :)

 

 

Hello again:]

 

I am wondering where should i put valid doctype

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

and meta tags

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

 

in a php file like this.

 

<?php

session_start(); // Session starts here
if(!isset($_SESSION['username'])) // If there is no session then...
{
    die ("<div align='center'><img src='images/LOGINKITTEN.jpg'/><br /><a href='index.php'><img src='images/Login.jpg'/></a></div>"); // ...Die!
} 

$id = $_GET['id'];

?>
<html>
<head>

<link rel="stylesheet" type="text/css" href="jamcss.css" />

</head>
<body>

<img src="images/jamspace.jpg" />
<div id="jamcontainer">
<b><a href="main.php">Home</a>  ||  <a href="members.php">Members</a>  ||  <a href="jams.php">Jams</a>  ||  <a href="uploadjamform.php">Upload Jam</a>  ||  <a href="myprofile.php">My profile</a>  ||  <a href="about.php">About</a>  ||  <a href="adminindex.php">Moderators</a> ||  <a href="logout.php">Logout</a></b>             You are logged in as <?php echo $_SESSION['username']; ?>
<br /><br />

<?php

$connection = mysql_connect("lol.com", "loldb", "lol00") or die ("Could not connect");
mysql_select_db("loldb", $connection) or die("Could not connect");

// mysql query to get the username
$query = mysql_query("SELECT * FROM news ORDER BY id DESC");
$numrows = mysql_num_rows($query);



if ($numrows!=0)
{
// fetching data from the database to variable
while ($row = mysql_fetch_assoc($query))
{
	$title = $row['title'];
	$post_owner = $row['post_owner'];
	$post = $row['post'];
	echo "<b>" . $title . "</b><br />";
	echo "Posted by <b>" . $post_owner . "</b><br /><br />";
	echo $post . "<hr></hr><br /><br />";
}
}

?>
</div>
</body>
</html>

Link to comment
Share on other sites

Does that happen on the flat html file or just when you use an include?

 

To be honest, and some may disagree here, but if you're using a strict Doc Type you're going to have to be a lot more sharp in your coding.  I generally always use a transitional doc type - i.e.:

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 

 

You may find it more forgiving. Let me know if that works :)

 

Drongo

 

For some reason doctype removes my css effects (only on IE)

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.