Welcome to WebmasterWorld Guest from 54.224.175.2

Forum Moderators: open

Message Too Old, No Replies

php page not displaying on opera

some of my pages wont show on opera

   
3:22 pm on Nov 22, 2009 (gmt 0)

5+ Year Member



Hey jus wondered if anybody could spot an obvious mistake or if im doing something wrong as my page wont display on the opera browser its fine on all other browsers including windoze, im using v 9.62, the codes below:

<?php echo "<xml version=\"1.0\" encoding=\"UTF-8\"/>\n"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/tr/xhtml1/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Blogs Start Page</title>
<link rel='stylesheet' type='text/css' href='style.css' />
<!-- compliance patch for microsoft browsers -->
<!--[if lt IE 7]>
<link rel='stylesheet' type='text/css' href='multi-column-ie.css' />
<script src="/ie7/ie7-standard-p.js" type="text/javascript"></script>
<![endif]-->
</head>
<body>
<div id='header'>
<h1 style="text-align:center">Welcome To Your Blog</h1>
<div id="navcontainer">
<ul id="navlist" style="text-align:center">
<li><a href="index.html">Home</a></li>
<li><a href="login.php">Login</a></li>
<li><a href="register.php">Register</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">Links</a></li>
</ul>
</div>
</div>
<div id='container'>
<div id='first-column'>

</div>
<?php
require 'include.php';
//connect to SQL server
$conn = mysql_connect($dbHost, $dbUser, $dbPass) or die ('Error connecting to mysql');
mysql_select_db($dbName) or die('Error, cant find database');

$retrieveQuery = mysql_query("SELECT blog_Id, blog_Title, blog_Created_Datetime, user_Name, location
FROM blogs, users
WHERE blogs.user_Id = users.user_Id ORDER BY blog_Created_Datetime DESC;");
$num = mysql_num_rows($retrieveQuery);

if ($num > 0)
{
?>
<div id='content'>
<h2 style="text-align:center;text-decoration:underline;">Latest Blog Titles</h2>
<p style="text-align:center"><a href = "blogswithentry.php" style='color:#FF0000'>View blogs with entries</a></p>
<hr class="ee"/>
<?php

$i=0;
while ($i<$num) {
$blogtitle = mysql_result($retrieveQuery,$i,"blog_Title");
$blogid = mysql_result($retrieveQuery,$i,"blog_Id");
$date = mysql_result($retrieveQuery,$i,"blog_Created_Datetime");
$username = mysql_result($retrieveQuery,$i,"user_Name");
$location = mysql_result($retrieveQuery,$i,"location");
$NewDate = date("d M Y, H:i:s", strtotime($date));
?>

<p style="text-align:center;color:#CD580A">
<?php echo $blogtitle;?><br />
<?php echo "<b>By:</b> ".$username .", ". $location ." ". '<span style="font-size:x-small;color:#224433">('.$NewDate.')</span>'; ?><br />
<?php echo "<a href = blog_details.php?id=$blogid style='font-size:small;color:#FF0000'>View full blog and add comments</a>";?>
<hr class="ee"/></p>
<?php

$i++;
}
?>

<?php
}
else if ($num == 0)
{

echo "No Records Found<br />";
echo '<a href="register.php">Register to add blogs</a>';
}
?>
</div>
<div id='third-column'>

</div>
</div>
<div id='footer'>
<h6 style="text-align:center">Blogs 2009 &copy; Abu Shahin</h6>
</div>
</body>
</html>

thanks in advance
Abu shahin

[edited by: tedster at 5:46 pm (utc) on Nov. 22, 2009]

3:57 pm on Nov 23, 2009 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



I'm not an Opera user, but I think the DOCTYPE declaration needs to be the first line (BEFORE the XML declaration). Maybe that is causing problems?
6:36 pm on Nov 23, 2009 (gmt 0)

5+ Year Member



hey yes it was thanks for that, i put it thru w3c/validator and that was the problem.
6:12 am on Nov 24, 2009 (gmt 0)

WebmasterWorld Senior Member jab_creations is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Incorrect, XHTML is a subset of XML and therefor you must declare XML before XHTML; you can't have the child before the parent.

If you think that was the fix you'll need to put the XML declaration first and reevaluate what you think it causing the problem. I highly recommend serving the page as application/xhtml+xml to very quickly discover if there are any XML errors that Opera is refusing to swallow.

- John

2:02 pm on Nov 24, 2009 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



@abushahin, it seems I was incorrect. If you include the xml declaration, it should appear before the DOCTYPE.
4:58 pm on Nov 24, 2009 (gmt 0)

5+ Year Member



hey i knew i had to have an xml declaration, but the one i had incorporated with php didnt seem to work so it worked after i removed it, i guess i was being lazy! ill just have to correct the syntax i guess.

well ive removed the original one which was
<?php echo "<xml version=\"1.0\" encoding=\"UTF-8\"/>\n"?>
TO
<?php echo ("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");?>
now opera doesnt have any probs neither does the validator hopefully that should settle it.

7:39 pm on Nov 24, 2009 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



Maybe a silly question, but why bother using PHP to echo out the XML declaration? Why not just include it in the actual document instead of using php echo?
9:57 pm on Nov 24, 2009 (gmt 0)

WebmasterWorld Senior Member jab_creations is a WebmasterWorld Top Contributor of All Time 10+ Year Member



A couple of things here...

First use single quotes in PHP to echo things unless you absolutely have to use double quotes. $variable will be echoed as a string in single quotes whereas with double quotes $variable will echo out whatever that variable contains...so single quotes reduce server load a little bit and every little bit helps right? Plus it's a lot less messy...

<?php echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";?>

Secondly if you can't get around not echoing the XML declaration with PHP since it'll interpret the <? part as a starting point for PHP.

I like the fact that you added the \n to keep your output clean looking. It really helps to debug stuff if your XHTML output is clean. :)

Also you'll learn a lot more and fix things a lot quicker if you serve XHTML pages as application/xhtml+xml at least in development environment. Some might say it's a pain and not worth the time though I've seen people blow entire days because of something simple such as missing quotes.

- John

10:49 pm on Nov 24, 2009 (gmt 0)

5+ Year Member



good points guys thanks for the input! abu
8:24 pm on Nov 25, 2009 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Does the document need to be XHTML; will HTML 4.01 do?