PDA

View Full Version : New to php and I screwed things up



luckyschop
01-21-2007, 05:33 PM
Below is the code to a document called app_layout_home.php. Not realizing that you could edit a doc's text from a webhost's cpanel (first mistake), I downloaded the php file and edited it in Nvu portable. I changed ONE line of code (in the html of all places --> near the bottom, it is the copyright date). Then I reuploaded the file and the result is this:

http://www.ehaplanners.com/index.php

the html gets rendered, but the php is not parsed.

All of the other pages work correctly (they use separate app_layout_"pagename".php files). Here is a properly functioning one:

http://www.ehaplanners.com/index.php?fuseaction=AboutUs

Could someone please help me figure out the problem? I am such a novice. Any help would be greatly appreciated.

Kyle





<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
&lt;?
$layout = "

<html>
<head>
<title>".$allsettings["setting_sitename"]."</title>
<script language='Javascript'>
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById('nav');
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=='LI') {
node.onmouseover=function() {
this.className+=' over';
}
node.onmouseout=function() {
this.className=this.className.replace(' over', '');
}
}
}
navRoot2 = document.getElementById('nav2');
for (i=0; i<navRoot2.childNodes.length; i++) {
node = navRoot2.childNodes[i];
if (node.nodeName=='LI') {
node.onmouseover=function() {
this.className+=' over';
}
node.onmouseout=function() {
this.className=this.className.replace(' over', '');
}
}
}
}
}
window.onload=startList;
</script>
<style>
BODY{scrollbar-3dlight-color : #B4CDEC;



... boring CSS stuff......



</style>

</head>

<body topmargin="0" leftmargin="0" rightmargin="0">

<ul id="nav" style="margin: 0pt; padding: 0pt; list-style-type: none; position: absolute; top: 190px; left: 250px;">

<li><a href="%22.$site_url.%22Services"><img src="images/spacer.gif" border="0" height="20" width="95"></a>
<ul>

<li><a href="%22.$site_url.%22LandPlanningServices">Land
Planning Services</a></li>

<li><a href="%22.$site_url.%22ExpertWitnessTestimony">Expert
Witness Testimony</a></li>

<li><a href="%22.$site_url.%22UrbanDesignLandscapeArchitecture">Urban
Design &amp; Landscape Architecture</a></li>

<li><a href="%22.$site_url.%22DevelopmentofRegionalImpact">Development
of Regional Impact</a></li>

<li><a href="%22.$site_url.%22SpecialStudies">Special
Studies</a></li>

<li><a href="%22.$site_url.%22RepresentativeClients">Representative
Clients</a></li>

</ul>

</li>

</ul>

<table bgcolor="white" border="0" cellpadding="0" cellspacing="0" width="100%">

<tbody>

<tr>

<td colspan="2" background="images/header_background.gif" height="92" width="100%">
<table cellpadding="0" cellspacing="0" width="100%">

<tbody>

<tr>

<td><a href="%22.$site_url.%22Home"><img src="images/header_left.gif" alt="" border="0" height="92" width="357"></a></td>

<td align="right"><a href="%22.$site_url.%22ContactUs"><img src="images/header_right.gif" alt="" border="0" height="92" width="364"></a></td>

</tr>

</tbody>
</table>

</td>

</tr>

<tr>

<td colspan="2" background="images/pic_top_background.gif" height="93" width="100%"><img src="images/pic_top.gif" alt="" border="0" height="93" width="750">
</td>

</tr>

<tr>

<td colspan="2" background="images/menu_top_background.gif" height="24" width="100%"><img src="images/menu_top.gif" alt="" usemap="#menu_top" border="0" height="24" width="750">
</td>

</tr>

<tr height="106">

<td valign="top" width="176"><img src="images/pic_menu.gif" alt="" border="0" height="106" width="176">
</td>

<td style="padding-right: 2px;" rowspan="2" valign="top">
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">

<tbody>

<tr>

<td height="25" width="8"><img src="images/content_topleft.gif" alt="" border="0" height="25" width="8"></td>

<td style="padding-bottom: 4px;" background="images/content_header.gif" height="25" valign="bottom"><img src="images/spacer.gif" alt="" border="0" height="1" width="1"><img src="images/title_%22.strtolower%28$fuseaction%29.%22.gif" alt="" border="0"></td>

<td height="25" width="8"><img src="images/content_topright.gif" alt="" border="0" height="25" width="8"></td>

</tr>

<tr>

<td background="images/content_left.gif"> <img src="images/spacer.gif" alt="" border="0" height="1" width="1"> </td>

<td style="padding-left: 5px;" padding-right:10="" padding-top:10="" padding-bottom:10="" bgcolor="#e9e9e9">
<div align="justify">".$bodycontent."</div>

</td>

<td background="images/content_right.gif"> <img src="images/spacer.gif" alt="" border="0" height="1" width="1"> </td>

</tr>

<tr>

<td height="14"><img src="images/content_bottomleft.gif" alt="" border="0" height="14" width="8"></td>

<td background="images/content_footer.gif" height="14" valign="top"><img src="images/spacer.gif" alt="" border="0" height="1" width="1"></td>

<td height="14"><img src="images/content_bottomright.gif" alt="" border="0" height="14" width="8"></td>

</tr>

</tbody>
</table>

</td>

</tr>

<tr>

<td background="images/leftmenu_background.gif" valign="top" width="176"> <input name="fuseaction" value="SearchNow" type="hidden">
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="176">

<tbody>

<tr>

<td height="17"><img src="images/search_keywords.gif" alt="" border="0" height="18" width="176"></td>

</tr>

<form action="index.php" method="post"></form>

<tr>

<td style="padding-left: 5px; padding-top: 5px; padding-bottom: 5px;" background="images/leftmenu_background.gif"> <input name="keywords" maxlength="35" size="15" type="text"> <input src="images/button_search.gif" align="center" type="image"> </td>

</tr>

<tr>

<td height="16"><img src="images/latest_news.gif" alt="" border="0" height="16" width="176"></td>

</tr>

<tr>

<td style="padding-left: 10px; padding-right: 10px;" background="images/leftmenu_background.gif"> ".$news." </td>

</tr>

</tbody>
</table>

</td>

</tr>

<tr>

<td colspan="2" background="images/menu_bottom_row_background.gif" height="12" width="100%"><img src="images/menu_bottom_row.gif" alt="" border="0" height="12" width="750"></td>

</tr>

<tr>

<td colspan="2" background="images/menu_bottom_background.gif" height="26" width="100%"><img src="images/menu_bottom.gif" alt="" usemap="#menu_bottom" border="0" height="26" width="750"></td>

</tr>

<tr>

<td colspan="2" align="center" background="images/footer.gif" height="53" valign="middle" width="100%">&copy; 2007
Engelhardt, Hammer &amp; Associates, Inc.</td>

</tr>

</tbody>
</table>

<ul id="nav2" style="margin: 0pt; padding: 0pt; list-style-type: none; position: relative; top: -75px; left: 260px;">

<li><a href="%22.$site_url.%22Services"><img src="images/spacer.gif" border="0" height="20" width="90"></a>
<ul>

<li><a href="%22.$site_url.%22LandPlanningServices">Land
Planning Services</a></li>

<li><a href="%22.$site_url.%22ExpertWitnessTestimony">Expert
Witness Testimony</a></li>

<li><a href="%22.$site_url.%22UrbanDesignLandscapeArchitecture">Urban
Design &amp; Landscape Architecture</a></li>

<li><a href="%22.$site_url.%22DevelopmentofRegionalImpact">Development
of Regional Impact</a></li>

<li><a href="%22.$site_url.%22SpecialStudies">Special
Studies</a></li>

<li><a href="%22.$site_url.%22RepresentativeClients">Representative
Clients</a></li>

</ul>

</li>

</ul>

<map name="header">
<area alt="Home" coords="2,0,348,81" href="%22.$site_url.%22Home">
<area alt="Email Us!" coords="579,46,738,59" href="%22.$site_url.%22ContactUs">
</map>

<map name="menu_top">
<area shape="RECT" coords="101,0,101,0">
<area alt="Home" coords="102,0,172,24" href="index.php">
<area alt="About Us" coords="173,1,258,26" href="%22.$site_url.%22AboutUs">
<area alt="Services" coords="259,0,348,24" href="%22.$site_url.%22Services">
<area alt="Staff" coords="349,0,418,24" href="%22.$site_url.%22Staff">
<area alt="Careers" coords="419,0,497,25" href="%22.$site_url.%22Careers">
<area alt="Links" coords="498,0,565,24" href="%22.$site_url.%22Links">
<area alt="Contact Us" coords="566,1,661,25" href="%22.$site_url.%22ContactUs">
</map>

<map name="menu_bottom">

<!--same as map menu top>

</map>

</body>
</html>

";
print $layout;
?&gt;

BLiZZaRD
01-21-2007, 05:41 PM
Change:



";
print $layout;
?&gt;


to:



<?php
print $layout;
?>


You have changed the actual php coding tags to HTML, so the browser/server sees them as HTML not PHP.

luckyschop
01-21-2007, 07:18 PM
that did not seem to work. nothing changed on the output --> it still renders as :

http://www.ehaplanners.com/index.php

I shouldn't have to insert <?php again should I? It is at the very top defining the variable $layout

BLiZZaRD
01-21-2007, 07:22 PM
Oops, my bad. I didn't see that one.

the same thing has happened to the top one as well. It should be the <?php
and then end with ?> at the bottom.

luckyschop
01-21-2007, 09:55 PM
it now gives me a php parse error on line 155

BLiZZaRD
01-22-2007, 12:19 AM
Oh dear me. LOL okay I took a closer look now and I see what happened.

ALL the php code that was on the page was turned into the HTML equivalent.

Do you have the original php file anywhere?

If not post the complete file, or better yet, put it in a zip file and attach it here so I (we) can help fix it.

luckyschop
01-22-2007, 07:18 PM
I was not here when the site was created, but I (stupidly) assumed that a backup was readily available. That not being the case, I am trying to get our IT guy to get a backup of the files (hopefully that will be fruitful).

I attached a zip of the file that I replaced the original with --> at the very beginning, I dl the app_layout_home.php file and edited it with Nvu, then reuploaded it. Something tells me that Nvu did not resave as a clean text file...

The attached file is a result of that, after I have edited it some using the cpanel of our hosting company.

Hope that all makes sense... I really do appreciate your help man

BLiZZaRD
01-23-2007, 02:06 AM
Okay I have the file, I will look at it and begin the fixing.

no promises on the time frame, there is a lot of code to go through. I will do it as speedily as I can though.

(If any other coder out there wants to help feel free :D )

thetestingsite
01-23-2007, 02:26 AM
Found problem, fixing code, will post when finished.

thetestingsite
01-23-2007, 02:35 AM
Ok, found the problem and it was with the quotes you put in the code. I fixed the code, and it is attached below. Please go through the code to see what I have done to fix it.

Hope this hleps.

733

BLiZZaRD
01-23-2007, 02:41 AM
Cool, thanks Test.

I was still about 3 hours away from even opening it :D

thetestingsite
01-23-2007, 02:42 AM
LMAO, not a problem. I love a challenge while at work. Currently programming DSL modems, watching "Revenge of the Nerds" (Internet TV), and viewing forums.

luckyschop
01-23-2007, 02:41 PM
test --> brilliant... it worked. home page parses correctly

couple questions...

I opened both old and your new with notepad and wordpad (eww) and did not see extra quotes... what/where did I miss?

which brings me to 2: quite the noob question but what text editor do you use to edit code? Nvu obviously did not do so hot, and notepad gives me a headache... are there not free progs that highlight certain parts of syntax for ease of reading?

again, many thanks to you, as well as BliZZaRD for your efforts. very much appreciated

(^_^)

luckyschop
01-23-2007, 02:47 PM
oh... the home page if you want to see it (not excited at ALL, yet)

http://www.ehaplanners.com

boxxertrumps
01-23-2007, 03:45 PM
BBnote.

http://i119.photobucket.com/albums/o141/boxxertrumps/note.jpg
Heres A Link... (http://bb4win.sourceforge.net/bblean/bbnote.htm)

BLiZZaRD
01-24-2007, 02:28 AM
I couldn't help with the editor part, I only use notepad. I hear notepad plus is nice though.

Oh, and NEVER use wordpad, it is NOT a plain text editor. It will do similar things to your codes as that Nvu did, most likely worse. :)

thetestingsite
01-26-2007, 02:45 PM
test --> brilliant... it worked. home page parses correctly

couple questions...

I opened both old and your new with notepad and wordpad (eww) and did not see extra quotes... what/where did I miss?


Well, about 1/4 ways down the page is where you got the error. It was there that there were unescaped quotation marks. I fixed the first couple of lines with a single quote ( ' ), then I got tired of doing that so I simply escaped the double quotes ( " ).

An example of the old code is as follows:



$test = "<a href="test.html">Testing</a>";


That would cause errors. Here are two simple fixes:



$test = "<a href='test.html'>Testing</a>";




$test = "<a href=\"test.html\">Testing</a>";




which brings me to 2: quite the noob question but what text editor do you use to edit code? Nvu obviously did not do so hot, and notepad gives me a headache... are there not free progs that highlight certain parts of syntax for ease of reading?


Well, I usually use Notepad when editing stuff locally. But when I want to test the code and edit the code pretty much at the same time, I use PHPFileNavigator (http://pfn.sourceforge.net/).

Hope this helps.