Code displaying in HTML Page
Moderator: General Moderators
Code displaying in HTML Page
I am creating a website where I want the basis of the page to be html with the code imbedded within. I am running into a problem that some of my PHP scripting is displaying as text on the HTML page. I have checked escaping my quotes, etc. any ideas? If you are curious as to what it looks like...here : http://www.ipdinfo.org
Robert
Robert
-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
And which part is the php code? I dont see any. Just remember:
Code: Select all
Out of php
<?php
//inside of php
echo "inside";
?>
outside- partiallynothing
- Forum Commoner
- Posts: 61
- Joined: Fri Nov 21, 2003 5:02 pm
- Location: connecticut, usa
Sami | Help us, help you. Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
I know some of the variables are off towards the mid of the php scripting....thats not the issue...the issue arises very early in the script.Code: Select all
<?php
<html>
<head>
<style type="text/css">
<!--
body,td,input { font-family: tahoma, helvetica; font-size: 11px; color: #B9B9B9; line-height: 18px; }
body { background-image: url('i/a1.jpg'); }
form { margin: 0px; }
a { text-decoration: none; color: #ffffff;}
a:hover { text-decoration: underline; color: #ffffff;}
.left { font-weight: bold; font-size: 10px; color: #ffffff; }
.emph { color: #ffffff; font-weight: bold; }
.nav { color: #666666; }
-->
</style>
</head>
<body rightmargin="0" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" rightmargin="0">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<img src="i/spacer.gif" width="1" height="22">
</td>
</tr>
<tr>
<td style="background-image: url('i/a5.jpg'); background-repeat: repeat-x"><a href="http://www.ipdinfo.org/"><img border="0" src="i/a4%20copy.jpg" width="772" height="139"></a></td>
</tr>
<tr>
<td style="background-image: url('i/a6.jpg'); background-repeat: repeat-x">
<table width="903" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="17"><img src="i/spacer.gif" width="16" height="1"></td>
<td width="99">
<p align="center"><img src="i/spacer.gif" width="16" height="1">
<a class=nav href="#">Repo Log</a><img src="i/spacer.gif" width="16" height="1"></p>
</td>
<td width="23"><img src="i/a8.jpg"></td>
<td width="104"><img src="i/spacer.gif" width="16" height="1">
<a class=nav href="#">Apt Guide</a><img src="i/spacer.gif" width="16" height="1">
</td>
<td width="23"><img src="i/a8.jpg"></td>
<td width="88"><img src="i/spacer.gif" width="16" height="1">
<a class=nav href="#">Vacation Watches</a><img src="i/spacer.gif" width="16" height="1">
</td>
<td width="24"><img src="i/a8.jpg"></td>
<td width="119"><img src="i/spacer.gif" width="16" height="1">
<a class=nav href="http://pound.ipdinfo.org">Pound Log</a><img src="i/spacer.gif" width="16" height="1">
</td>
<td width="26"><img src="i/a8.jpg"></td>
<td width="114"><img src="i/spacer.gif" width="16" height="1">
<a class=nav href="http://www.ipdinfo.org/pound/users.php">Database Users</a>
<img src="i/spacer.gif" width="16" height="1"></td>
<td width="24"><img src="i/a8.jpg"></td>
<td width="62"><img src="i/spacer.gif" width="16" height="1">
<a class=nav href="#">Admin</a><img src="i/spacer.gif" width="16" height="1">
</td>
<td width="154"><img src="i/spacer.gif"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="background-image: url('i/a19.jpg'); background-repeat: repeat-x"><img src="i/a19.jpg"></td>
</tr>
<tr>
<td style="background-image: url('i/a34.jpg')">
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="background-image: url('i/a28.jpg'); background-repeat: repeat-x">
<tr>
<td><img src="i/spacer.gif" width="9" height="1"></td>
<td valign="top">
<table cellpadding="0" cellspacing="0" border="0" width="166">
<tr>
<td colspan="4"><img src="i/spacer.gif" width="1" height="35"></td>
</tr>
<tr>
<td width="149" align="right">
<a href="#" class="left">FIRST PAGE LINK</a>
</td>
<td><img src="i/spacer.gif" width="11" height="34"></td>
<td><img src="i/a90.jpg"></td>
<td><img src="i/spacer.gif" width="2" height="1"></td>
</tr>
<tr>
<td colspan="4"><img src="i/a37.jpg"></td>
</tr>
<tr>
<td width="149" align="right">
<a href="#" class="left">SECOND PAGE LINK</a>
</td>
<td><img src="i/spacer.gif" width="11" height="34"></td>
<td><img src="i/a90.jpg"></td>
<td><img src="i/spacer.gif" width="2" height="1"></td>
</tr>
<tr>
<td colspan="4"><img src="i/a37.jpg"></td>
</tr>
<tr>
<td width="149" align="right">
<a href="#" class="left">THIRD PAGE LINK</a>
</td>
<td><img src="i/spacer.gif" width="11" height="34"></td>
<td><img src="i/a90.jpg"></td>
<td><img src="i/spacer.gif" width="2" height="1"></td>
</tr>
<tr>
<td colspan="4"><img src="i/a37.jpg"></td>
</tr>
<tr>
<td width="149" align="right">
<a href="#" class="left">FOURTH PAGE LINK</a>
</td>
<td><img src="i/spacer.gif" width="11" height="34"></td>
<td><img src="i/a90.jpg"></td>
<td><img src="i/spacer.gif" width="2" height="1"></td>
</tr>
<tr>
<td colspan="4"><img src="i/a37.jpg"></td>
</tr>
<tr>
<td width="149" align="right">
<a href="#" class="left">FIFTH PAGE LINK</a>
</td>
<td><img src="i/spacer.gif" width="11" height="34"></td>
<td><img src="i/a90.jpg"></td>
<td><img src="i/spacer.gif" width="2" height="1"></td>
</tr>
<tr>
<td colspan="4"><img src="i/a37.jpg"></td>
</tr>
<tr>
<td width="149" align="right">
<a href="#" class="left">SIXTH PAGE LINK</a>
</td>
<td><img src="i/spacer.gif" width="11" height="34"></td>
<td><img src="i/a90.jpg"></td>
<td><img src="i/spacer.gif" width="2" height="1"></td>
</tr>
</table>
</td>
<td><img src="i/spacer.gif" width="9" height="1"></td>
<td style="background-image: url('i/a26.jpg'); background-repeat: repeat-y"><img src="i/a26.jpg"></td>
<td><img src="i/spacer.gif" width="23" height="1"></td>
<td width="100%" valign="top">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td><img src="i/spacer.gif" width="1" height="35"></td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td><img src="i/a33.jpg"></td><td><h2>News</h2></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><img src="i/spacer.gif" width="1" height="22"></td>
</tr>
<tr>
<td>
<?
//include connection script
include('./connect.php');
//specify query to be run
$query="SELECT start,title,news FROM news WHERE (start>=CURDATE() AND end<=CURDATE()) ORDER BY 'start' DESC";
//assign query result to variable
$result=mysql_query($query);
//display data in the users table
if ($result) { //check to see if result returns
//display table header row
echo '<table align="left" cellspacing="0" cellpadding="2" border="0">';
//assign number of rows to variable for loop
$num=mysql_numrows($result);
//begin loop to display data in each row
for ($i=0; $i<$num; $i++){
//assign values to variables within loop to display
$id=mysql_result($result,$i,"id");
$fname=mysql_result($result,$i,"first");
$lname=mysql_result($result,$i,"last");
$rank=mysql_result($result,$i,"rank");
echo "<tr><td align="center"> $id </td>";
echo "<td align="center"> $lname, $fname </td>";
echo "<td align="center">$rank</td></tr>";
}
//print end of table
echo '</table>';
//release memory used by query
mysql_free_result($result);
} else {
//error with getting query
echo '<p>Users could not be displayed</p>';
}
mysql_close();
?>
<br>
<br>
</td>
</tr>
</table>
</td>
<td><img src="i/spacer.gif" width="60" height="1"></td>
</tr>
</table>
<br>
</td>
</tr>
<tr>
<td style="background-image: url('i/a38.jpg'); background-repeat: repeat-x"><img src="i/a38.jpg"></td>
</tr>
<tr>
<td align="center">
Copyright © 2004 <a href="http://www.ipdinfo.org">ipdinfo.org</a>. All rights reserved. Hosting provided by <a href="http://www.xenhosting.com">XenHosting.com</a>
</td>
</tr>
</table>
</body>
</html>
?>-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
Please use the tags to put your code so it looks pretty and it might catch the error.
You dont have to keep calling echo on each line:
Then try to escape from the string before you print the vars, like:
You dont have to keep calling echo on each line:
Code: Select all
echo "
this is
just
as
good
or
add
newlines /n
/n
";Code: Select all
echo "
this and ".$var."
etc.
";
Last edited by kettle_drum on Wed Oct 13, 2004 5:18 pm, edited 1 time in total.
- partiallynothing
- Forum Commoner
- Posts: 61
- Joined: Fri Nov 21, 2003 5:02 pm
- Location: connecticut, usa
Always place your code in the [*php][*/php] (minus the *s) tags, so it is nicely highlighted.
Code: Select all
<html>
<head>
<style type="text/css">
<!--
body,td,input { font-family: tahoma, helvetica; font-size: 11px; color: #B9B9B9; line-height: 18px; }
body { background-image: url('i/a1.jpg'); }
form { margin: 0px; }
a { text-decoration: none; color: #ffffff;}
a:hover { text-decoration: underline; color: #ffffff;}
.left { font-weight: bold; font-size: 10px; color: #ffffff; }
.emph { color: #ffffff; font-weight: bold; }
.nav { color: #666666; }
-->
</style>
</head>
<body rightmargin="0" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" rightmargin="0">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<img src="i/spacer.gif" width="1" height="22">
</td>
</tr>
<tr>
<td style="background-image: url('i/a5.jpg'); background-repeat: repeat-x"><a href="http://www.ipdinfo.org/"><img border="0" src="i/a4%20copy.jpg" width="772" height="139"></a></td>
</tr>
<tr>
<td style="background-image: url('i/a6.jpg'); background-repeat: repeat-x">
<table width="903" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="17"><img src="i/spacer.gif" width="16" height="1"></td>
<td width="99">
<p align="center"><img src="i/spacer.gif" width="16" height="1">
<a class=nav href="#">Repo Log</a><img src="i/spacer.gif" width="16" height="1"></p>
</td>
<td width="23"><img src="i/a8.jpg"></td>
<td width="104"><img src="i/spacer.gif" width="16" height="1">
<a class=nav href="#">Apt Guide</a><img src="i/spacer.gif" width="16" height="1">
</td>
<td width="23"><img src="i/a8.jpg"></td>
<td width="88"><img src="i/spacer.gif" width="16" height="1">
<a class=nav href="#">Vacation Watches</a><img src="i/spacer.gif" width="16" height="1">
</td>
<td width="24"><img src="i/a8.jpg"></td>
<td width="119"><img src="i/spacer.gif" width="16" height="1">
<a class=nav href="http://pound.ipdinfo.org">Pound Log</a><img src="i/spacer.gif" width="16" height="1">
</td>
<td width="26"><img src="i/a8.jpg"></td>
<td width="114"><img src="i/spacer.gif" width="16" height="1">
<a class=nav href="http://www.ipdinfo.org/pound/users.php">Database Users</a>
<img src="i/spacer.gif" width="16" height="1"></td>
<td width="24"><img src="i/a8.jpg"></td>
<td width="62"><img src="i/spacer.gif" width="16" height="1">
<a class=nav href="#">Admin</a><img src="i/spacer.gif" width="16" height="1">
</td>
<td width="154"><img src="i/spacer.gif"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="background-image: url('i/a19.jpg'); background-repeat: repeat-x"><img src="i/a19.jpg"></td>
</tr>
<tr>
<td style="background-image: url('i/a34.jpg')">
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="background-image: url('i/a28.jpg'); background-repeat: repeat-x">
<tr>
<td><img src="i/spacer.gif" width="9" height="1"></td>
<td valign="top">
<table cellpadding="0" cellspacing="0" border="0" width="166">
<tr>
<td colspan="4"><img src="i/spacer.gif" width="1" height="35"></td>
</tr>
<tr>
<td width="149" align="right">
<a href="#" class="left">FIRST PAGE LINK</a>
</td>
<td><img src="i/spacer.gif" width="11" height="34"></td>
<td><img src="i/a90.jpg"></td>
<td><img src="i/spacer.gif" width="2" height="1"></td>
</tr>
<tr>
<td colspan="4"><img src="i/a37.jpg"></td>
</tr>
<tr>
<td width="149" align="right">
<a href="#" class="left">SECOND PAGE LINK</a>
</td>
<td><img src="i/spacer.gif" width="11" height="34"></td>
<td><img src="i/a90.jpg"></td>
<td><img src="i/spacer.gif" width="2" height="1"></td>
</tr>
<tr>
<td colspan="4"><img src="i/a37.jpg"></td>
</tr>
<tr>
<td width="149" align="right">
<a href="#" class="left">THIRD PAGE LINK</a>
</td>
<td><img src="i/spacer.gif" width="11" height="34"></td>
<td><img src="i/a90.jpg"></td>
<td><img src="i/spacer.gif" width="2" height="1"></td>
</tr>
<tr>
<td colspan="4"><img src="i/a37.jpg"></td>
</tr>
<tr>
<td width="149" align="right">
<a href="#" class="left">FOURTH PAGE LINK</a>
</td>
<td><img src="i/spacer.gif" width="11" height="34"></td>
<td><img src="i/a90.jpg"></td>
<td><img src="i/spacer.gif" width="2" height="1"></td>
</tr>
<tr>
<td colspan="4"><img src="i/a37.jpg"></td>
</tr>
<tr>
<td width="149" align="right">
<a href="#" class="left">FIFTH PAGE LINK</a>
</td>
<td><img src="i/spacer.gif" width="11" height="34"></td>
<td><img src="i/a90.jpg"></td>
<td><img src="i/spacer.gif" width="2" height="1"></td>
</tr>
<tr>
<td colspan="4"><img src="i/a37.jpg"></td>
</tr>
<tr>
<td width="149" align="right">
<a href="#" class="left">SIXTH PAGE LINK</a>
</td>
<td><img src="i/spacer.gif" width="11" height="34"></td>
<td><img src="i/a90.jpg"></td>
<td><img src="i/spacer.gif" width="2" height="1"></td>
</tr>
</table>
</td>
<td><img src="i/spacer.gif" width="9" height="1"></td>
<td style="background-image: url('i/a26.jpg'); background-repeat: repeat-y"><img src="i/a26.jpg"></td>
<td><img src="i/spacer.gif" width="23" height="1"></td>
<td width="100%" valign="top">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td><img src="i/spacer.gif" width="1" height="35"></td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td><img src="i/a33.jpg"></td><td><h2>News</h2></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><img src="i/spacer.gif" width="1" height="22"></td>
</tr>
<tr>
<td>
<?
//include connection script
include('./connect.php');
//specify query to be run
$query="SELECT start,title,news FROM news WHERE (start>=CURDATE() AND end<=CURDATE()) ORDER BY 'start' DESC";
//assign query result to variable
$result=mysql_query($query);
//display data in the users table
if ($result) { //check to see if result returns
//display table header row
echo '<table align="left" cellspacing="0" cellpadding="2" border="0">';
//assign number of rows to variable for loop
$num=mysql_numrows($result);
//begin loop to display data in each row
for ($i=0; $i<$num; $i++){
//assign values to variables within loop to display
$id=mysql_result($result,$i,"id");
$fname=mysql_result($result,$i,"first");
$lname=mysql_result($result,$i,"last");
$rank=mysql_result($result,$i,"rank");
echo "<tr><td align="center"> $id </td>";
echo "<td align="center"> $lname, $fname </td>";
echo "<td align="center">$rank</td></tr>";
}
//print end of table
echo '</table>';
//release memory used by query
mysql_free_result($result);
} else {
//error with getting query
echo '<p>Users could not be displayed</p>';
}
mysql_close();
?>
<br>
<br>
</td>
</tr>
</table>
</td>
<td><img src="i/spacer.gif" width="60" height="1"></td>
</tr>
</table>
<br>
</td>
</tr>
<tr>
<td style="background-image: url('i/a38.jpg'); background-repeat: repeat-x"><img src="i/a38.jpg"></td>
</tr>
<tr>
<td align="center">
Copyright © 2004 <a href="http://www.ipdinfo.org">ipdinfo.org</a>. All rights reserved. Hosting provided by <a href="http://www.xenhosting.com">XenHosting.com</a>
</td>
</tr>
</table>
</body>
</html>
Last edited by partiallynothing on Wed Oct 13, 2004 5:20 pm, edited 1 time in total.
- partiallynothing
- Forum Commoner
- Posts: 61
- Joined: Fri Nov 21, 2003 5:02 pm
- Location: connecticut, usa
- partiallynothing
- Forum Commoner
- Posts: 61
- Joined: Fri Nov 21, 2003 5:02 pm
- Location: connecticut, usa
-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
-
Shendemiar
- Forum Contributor
- Posts: 404
- Joined: Thu Jan 08, 2004 8:28 am
Make sure you have error reporting on
Code: Select all
<?php
error_reporting(E_ALL);
?>- harrisonad
- Forum Contributor
- Posts: 288
- Joined: Fri Oct 15, 2004 4:58 am
- Location: Philippines
- Contact:
i found these:
1.) echo '<table align="left" cellspacing="0" cellpadding="2" border="0">';
sometimes error rises from simple string handling: i advise you to practice enclosing the (') between the ("), like this: "this is 'your' string".
2.) $num=mysql_numrows($result);
take care of function spelling. this should be: mysql_num_rows($result)
i also advise you to have an editor with keyword-highlighting feature for you to see those misspelled functions
i hope that helped....
1.) echo '<table align="left" cellspacing="0" cellpadding="2" border="0">';
sometimes error rises from simple string handling: i advise you to practice enclosing the (') between the ("), like this: "this is 'your' string".
2.) $num=mysql_numrows($result);
take care of function spelling. this should be: mysql_num_rows($result)
i also advise you to have an editor with keyword-highlighting feature for you to see those misspelled functions
i hope that helped....
Help us, help you. Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]