Forum Moderators: coopster

Message Too Old, No Replies

Parse Errors and Newbie Knows Nothing

Totally fubared it and don't know what to do.

         

Bailey

9:25 am on Feb 25, 2005 (gmt 0)

10+ Year Member



I have NO idea what I did.

I have to maintain a PHP/HTML hybrid site with no PHP knowledge. I've been able to go in and through close scrutiny make necessary changes to the the PHP code from time to time.

However, tonight when I was doing some "updating" I accidentally over-wrote the existing WORKING code.

Of course now it doesn't work.

I am getting this Parse Error:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/hlibftp/public_html/view_story.php on line 112

I've pasted the whole darn code below.
Line 112 is marked with **** for "ease" of finding. I've looked at it, topways and sideways and can't see the error.

I'm gonna be lynched if I don't get it sorted but quick.

Hellllllllp!

Please?

Bailey

___________________________________________________

<?php

[snip]

echo<<<EOM

<html>
[snip]
<body>

[snip]

<style type="text/css">
a {color:#FFFFFF}
body, td {font: 12pt Verdana,Arial; color: #FFFFFF}
</style>
[snip]

</script>
</HEAD>
<BODY BGCOLOR='#000000' TOPMARGIN='0' BOTTOMMARGIN='0' LEFTMARGIN='0' RIGHTMARGIN='0'>
<?
$update_story = mysql_query("UPDATE stories SET views=views+1 WHERE id='$id' OR id='$story_id'");
$select_story = mysql_query("SELECT * FROM users u,stories s WHERE u.id = s.author_id and (s.id='$id' OR s.id='$story_id')");
$fetch_story = mysql_fetch_array($select_story);
****$author_name = $fetch_story['full_name'];****
$author_email = $fetch_story['email_address'];
[snip]
?>
</BODY>
</HTML>

EOM;

mysql_close();

?>

[edited by: ergophobe at 5:17 pm (utc) on Feb. 25, 2005]
[edit reason] Please read forum charter regarding posting code [/edit]

grandpa

11:44 am on Feb 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



<errp>No.. I was wrong.. could still be that way..

It looks like your SELECT is failing.
$fetch_story = mysql_fetch_array($select_story);

Try echoing $select_story just before you do $fetch_story and see what is in your query.

echo "<br>SELECT = $select_story";
$fetch_story = mysql_fetch_array($select_story);

Also, this line is commented in upper routine, but not in the lower:
$story_title = $fetch_story['title'];// RepChars($story_title);
The pair of slashes represents the beginning of a comment.

You might try commenting it in the lower routine... It's a call to an undefined function as far as I can tell although most likely defined somewhere.

Bailey

4:39 pm on Feb 25, 2005 (gmt 0)

10+ Year Member



Thanks for the suggestions. Tried both one at a time and then together. No luck.

However, when I remove the following block of code from the lower group, the page will show up with errors on it (missing story title, missing author, missing print-friendly link and icon).

*****

$update_story = mysql_query("UPDATE stories SET views=views+1 WHERE id='$id' OR id='$story_id'");
$select_story = mysql_query("SELECT * FROM users u,stories s WHERE u.id = s.author_id and (s.id='$id' OR s.id='$story_id')");
$fetch_story = mysql_fetch_array($select_story);
$author_name = $fetch_story['full_name'];
$author_email = $fetch_story['email_address'];
$story_title = $fetch_story['title'];// RepChars($story_title);
$story = $fetch_story['story'];
$story_indents = $fetch_story['indents'];
if($story_indents=='1')
{
$story = str_replace("\n", "<BR>&nbsp; &nbsp; ", $story);
}else
{
$story = str_replace("\n", "<BR>", $story);
}
$story = str_replace(" ", "&nbsp; &nbsp; ", $story);
//$story = str_replace(" ", "&nbsp;", $story);
$story_time = $fetch_story['time'];
$date_posted = date("r", $story_time);

*****

This must mean it's in there somewhere. I've managed to put up a temporary solution so the stories are still accessible in the print friendly format (yayy for options) but I really nead the main read page to come up properly.

...is now working on about 4 hours of sleep...

Thanks again for any and all help!

ergophobe

5:20 pm on Feb 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The original code had tons of nesting errors.

- body tags within body tags for the html
- php within php as in

<? This is php
<? This is more php?>

some other stuff

?>

Check out the forum charter [webmasterworld.com] which has a link to a thread on Troubleshooting 101 that is aimed at helping people work through these things in a systematic way.

Bailey

5:30 pm on Feb 25, 2005 (gmt 0)

10+ Year Member



Thanks I will.

I didn't create this code. My job is simply to try and maintain and make minor edits to it.

I'm failing at that task.

Bailey

ergophobe

5:38 pm on Feb 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Don't worry. You'll get better fast!

Looking at the code you're being asked to maintain, it looks like trial by fire!

gettopreacherman

8:02 pm on Feb 25, 2005 (gmt 0)

10+ Year Member



<?php

[snip]

echo<<<EOM
?>
<html>
[snip]
<body>

[snip]

<style type="text/css">
a {color:#FFFFFF}
body, td {font: 12pt Verdana,Arial; color: #FFFFFF}
</style>
[snip]

</script>
</HEAD>
<BODY BGCOLOR='#000000' TOPMARGIN='0' BOTTOMMARGIN='0' LEFTMARGIN='0' RIGHTMARGIN='0'>

<?
$update_story = mysql_query("UPDATE stories SET views=views+1 WHERE id='$id' OR id='$story_id'");
$select_story = mysql_query("SELECT * FROM users u,stories s WHERE u.id = s.author_id and (s.id='$id' OR s.id='$story_id')");
$fetch_story = mysql_fetch_array($select_story);
****$author_name = $fetch_story['full_name'];****
$author_email = $fetch_story['email_address'];
[snip]
?>

</BODY>
</HTML>

<?php
EOM;

mysql_close();

?>

[edited

Bailey

1:07 am on Feb 27, 2005 (gmt 0)

10+ Year Member



Ok...

So I've managed to figure out how to get the data showing, and in the right place but now I'm dealing with one last issue.

What I'm trying to do is select a story from the database, which it is doing. However, it is showing the data about 8 times (along with some code) before it shows the data properly (with the '?>' code at the end).

I've re-posted the beginning and end of the code, taking out the stuff that I know is working.

I hope this isn't too much code.

Any suggestions as to why the repeating story info is happening?

____________________________________________

<?php

[snip]

$year = date("Y");

$update_story = mysql_query("UPDATE stories SET views=views+1 WHERE id='$id' OR id='$story_id'");
$select_story = mysql_query("SELECT * FROM users u,stories s WHERE u.id = s.author_id and (s.id='$id' OR s.id='$story_id')");
$fetch_story = mysql_fetch_array($select_story);
$author_name = $fetch_story['full_name'];
$author_email = $fetch_story['author_email'];
$story_title = $fetch_story['title'];// RepChars($story_title);
$story = $fetch_story['story'];
$story_indents = $fetch_story['indents'];
if($story_indents=='1')
{
$story = str_replace("\n", "<BR>&nbsp; &nbsp; ", $story);
}else
{
$story = str_replace("\n", "<BR>", $story);
}
$story = str_replace(" ", "&nbsp; &nbsp; ", $story);
//$story = str_replace(" ", "&nbsp;", $story);
$story_time = $fetch_story['time'];
$date_posted = date("r", $story_time);

echo<<<EOM

<HTML>

[snip]

<?
$update_story = mysql_query("UPDATE stories SET views=views+1 WHERE id='$id' OR id='$story_id'");
$select_story = mysql_query("SELECT * FROM users u, stories s WHERE u.id = s.author_id and (s.id='$id' OR s.id='$story_id')");
$fetch_story = mysql_fetch_array($select_story);
$author_name = $fetch_story[full_name];
$author_email = $fetch_story[email_address];
$story_title = $fetch_story[title]//RepChars($story_title);
$story = $fetch_story[story];
$story_indents = $fetch_story[indents];
if($story_indents=='1')
{
$story = str_replace("\n", "<BR>&nbsp; &nbsp; ", $story);
}else
{
$story = str_replace("\n", "<BR>", $story);
}
$story = str_replace(" ", "&nbsp; &nbsp; ", $story);
//$story = str_replace(" ", "&nbsp;", $story);
$story_time = $fetch_story[time];
$date_posted = date("r", $story_time);
$story_title</font></td><td align='right'><font size='-1'><a href=\"javascript:PopWin($story_id)\" style='text-decoration:none'><img src="\images\print.jpg" alt=\"Print\" border=\"0\" align='middle'> View printer-friendly version</a></font></td></tr></table>
<BR>
<FONT SIZE='-1'>By <A HREF='mailto:$author_email'><B>$author_name</B></A><BR><br><br>
$story";

?>

</font>
</TD>
</TR>
</TABLE>

</BODY>
</HTML>

<?php
EOM;

mysql_close();

?>