Forum Moderators: coopster
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]
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.
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> ", $story);
}else
{
$story = str_replace("\n", "<BR>", $story);
}
$story = str_replace(" ", " ", $story);
//$story = str_replace(" ", " ", $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!
- 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.
[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
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> ", $story);
}else
{
$story = str_replace("\n", "<BR>", $story);
}
$story = str_replace(" ", " ", $story);
//$story = str_replace(" ", " ", $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> ", $story);
}else
{
$story = str_replace("\n", "<BR>", $story);
}
$story = str_replace(" ", " ", $story);
//$story = str_replace(" ", " ", $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();
?>