PDA

View Full Version : Debugging PHP - Not Sure What I'm Doing Wrong - Parse Error


N2ChristTheKing
01-21-2004, 03:28 PM
Moved Here, sorry mods, I didn't see this forum until after I posted.

------

Hey guys, I'm having trouble with a page I'm doing in PHP. I'm brand new to PHP and am trying to learn it but I have to finish this page quickly and I need some help.

The page is here:

http://www.kc-mtm.com/portfolio/ccwc04/ccwc.php

The PHP I modified from this thread:

http://www.htmlforums.com/showthread.php?s=&threadid=32068

Here is my full source:
http://www.kc-mtm.com/portfolio/ccwc04/ccwc.txt
http://www.kc-mtm.com/portfolio/ccwc04/preface.txt

Here's the cut down version:


<body>

<!--Background Images-->
<div ID="graphics">

<div ID="gr_top">
<img src="images/top.jpg">
</div>

<div ID="gr_bottom-left">
<img src="images/bottom-left.jpg">
</div>

<div ID="gr_video">

<?PHP
if (!$vidoedisplay){
print "<img src=\"images/video.jpg\">";
}else{
if ($preface == "300k"){
include ("/videos/qt/300k/preface.php");
}
?>

</div>

<div ID="gr_bottom">
<img src="images/bottom.jpg">
</div>

<div ID="gr_bottom-right">
<img src="images/bottom-right.jpg">
</div>
</div>
<!--/Background Images-->

<table ID="maintable">
<tr>
<td rowspan="3" class="video-title">Preface</td>
<td class="video-format">QuickTime:</td>
<td class="video-size">56k</td>
<td class="video-size">100k</td>
<td class="video-size"><a href="ccwc.php?videodisplay=yes&preface=300k">300k</a></td>
</tr>
<tr class="coming-soon">
<td class="video-format">Windows Media:</td>
<td class="video-size">56k</td>
<td class="video-size">100k</td>
<td class="video-size">300k</td>
</tr>
<tr class="coming-soon">
<td class="video-format">Real:</td>
<td class="video-size">56k</td>
<td class="video-size">100k</td>
<td class="video-size">300k</td>
<tr>
</table>


Here's the preface.php:


print "<embed src=\"videos/qt/300k/preface.mov\" height=\"336\" width=\"240\" autoplay=\"true\" controller=\"true\" kioskmode=\"true\" loop=\"false\">";


And the Parse Error:

Parse error: parse error in /home/kcmtm02/public_html/portfolio/ccwc04/ccwc.php on line 205

Can anyone help me figure out what I'm doing wrong and how I might fix it.

n8thegreat
01-21-2004, 03:43 PM
youre missing a }


if (!$vidoedisplay) {
print "<img src=\"images/video.jpg\">";
} else {
if ($preface == "300k") {
include ("/videos/qt/300k/preface.php");
}
}


tip: always indent correctly so you dont miss any closing brackets

N2ChristTheKing
01-21-2004, 03:54 PM
Thanks, that did it!

So I guess my next question, when I click on my 300k link (the only live link on the right page) it's not doing what I hoped I thought it would. Basically I wanted to image of the montains on the left page to go away and the video to be there instead.

Specifically this is what I have:

<?PHP
if (!$vidoedisplay) {
print "<img src=\"images/video.jpg\">";
} else {
if ($preface == "300k") {
include ("/videos/qt/300k/preface.php");
}
}
?>

This is to tell it that when I click on the specific link it will exchange video.jpg for the code from preface.php.

<td class="video-size"><a href="ccwc.php?videodisplay=yes&preface=300k">300k</a></td>

That's the link that should trigger the change.

print "<embed src=\"videos/qt/300k/preface.mov\" height=\"336\" width=\"240\" autoplay=\"true\" controller=\"true\" kioskmode=\"true\" loop=\"false\">";

That's the code I want to exchange it with.

Am I using the embed or print (should it be echo?) functions wrong? Could my problem be in the HTML rather than the PHP?

Thanks!

illogique
01-21-2004, 04:16 PM
if (!$vidoedisplay) {

should be

if (!$videodisplay) {

N2ChristTheKing
01-21-2004, 04:16 PM
One other thing, I already know my CSS is screwed up, so if the page layout look really bad, I'm working on it.

N2ChristTheKing
01-21-2004, 04:37 PM
illogique,

Now I really feel stupid :D That got me much closer though, but now in the box where the video should be I'm getting:

{ print ""; }

What should I have in their? Should it be just the HTML embed or should it still be PHP code?

illogique
01-21-2004, 05:33 PM
Originally posted by N2ChristTheKing
illogique,

Now I really feel stupid :D

and again...

you don't have <?php ?> in preface.php

N2ChristTheKing
01-21-2004, 05:39 PM
Okay, so you need to have <?php ?> in the include? I was told that it just replaces the include so the end result would be:

<?PHP
if (!$vidoedisplay) {
print "<img src=\"images/video.jpg\">";
} else {
if ($preface == "300k") {
print "<embed src=\"videos/qt/300k/preface.mov\" height=\"336\" width=\"240\" autoplay=\"true\" controller=\"true\" kioskmode=\"true\" loop=\"false\">";
}
?>

I guess that's not how it works then. I'll try it again, thanks, I'm really sorry I'm so clueless, I'm trying to learn PHP, web-design isn't my job but I was asked to do it.

N2ChristTheKing
01-21-2004, 05:49 PM
It works!!! Thank you soooo much, I'm really sorry to bother you guys with my ignorance, here, thank you for bearing with me. I honestly can't thank you enough.

illogique
01-21-2004, 05:54 PM
look at the online docs of php for include
http://ca2.php.net/include/

but because preface.php is static, you don't need php, it could be only html.

then again, you could only have 1 file the include that will check variable and dispaly the correct image or video...

N2ChristTheKing
01-21-2004, 06:15 PM
Will do, thanks for the link.

I'm considering having only one file, but for the smaller video sizes I'll actually be including four images around the video so I'd rather people don't have to load all that extra code or at least keep it a little less cluttered.

giz
01-23-2004, 05:24 PM
Although you might think your mistakes are silly, to the next person browsing this forum with a similar problem, this thread might just give the enlightenment that they need.


Run the page that is output from that script through the code validator at http://validator.w3.org/detailed.html and see if you can get the HTML output to conform to, say, the HTML 4.01 Transitional standard. That would be a good next step.

N2ChristTheKing
01-31-2004, 08:01 PM
Okay, gotten the PHP fixed and working, and I had the whole QuickTime part of it up and working, but I made a planning mistake and am having to redo some thing for Windows Media to work. So in the process I've decided to try to get it to conform to XHTML Strict or at least Transitional, as well as fixing some CSS and other misc. problems.

The reason I'm posting is that before I add the table with the PHP links to the page it validates just fine, once I add it I get tons of errors and I'm not clear on what they actually mean.

The updated test page is here:
http://localhost/version_02/ccwc.php

And validation results here:
http://validator.w3.org/check?uri=http%3A%2F%2Fwww.kc-mtm.com%2Fportfolio%2Fccwc_xhtml_test%2Fccwc.php

Here's the problems I'm getting:

Note: The Validator XML support has some limitations.
Line 47, column 61: cannot generate system identifier for general entity "preface"
Line 47, column 68: reference not terminated by REFC delimiter
Line 47, column 68: reference to external entity in attribute value
Line 48, column 68: reference not terminated by REFC delimiter
Line 48, column 68: reference to external entity in attribute value
Line 49, column 68: reference not terminated by REFC delimiter
Line 49, column 68: reference to external entity in attribute value
Also see the attached 12k .gif screenshot (I didn't know how to format that right for the forum)

The code in question is:

<td class="video-size"><a href="ccwc.php?videodisplay=yes&preface=qt_40k">40k</a></td>
These errors and the code continue on with more of the same, but I think that's the gist of it.

Is there a way to make this code conform to XHTML?

PS: I know none of the links work right now, I'm just getting this page working then I'll move on to those.

scoutt
02-01-2004, 11:39 AM
all of these
<td class="video-size"><a href="ccwc.php?videodisplay=yes&preface=qt_40k">40k</a></td>

need to be this

<td class="video-size"><a href="ccwc.php?videodisplay=yes&amp;amp;preface=qt_40k">40k</a></td>

N2ChristTheKing
02-01-2004, 01:03 PM
Works perfect, thanks! :banger: