Jump to content

Help! What does this mean? expecting `T_STRING'


morocco-iceberg

Recommended Posts

Here's the line causing the error. This line is the data that is supposed to written to a new page.

 

 

blog="<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>Subscribe to Club Newsletter</title></head><body><h2>.$title.</h2><p>.$article.</p><h4>.$author. @ .$time.</h4><br/><br/><?php $commentFile=\".$label..txt\"\;	$readComment=fopen(.$commentFile.,\'r\')\;	.$showComment.=fread(.$readComment.,filesize(.$commentFile.))\; fclose($readComment)\; echo .$showComment.\; if(isset($_POST[\'commentsubmit\'])){ .$addComment.=fopen(.$commentFile.,\'a\')\; .$comment.=$_POST[\'comment\']\; .$commentauthor.=$_POST[\'commentauthor\']\; .$commenttime.=date(\"g:i a M j, Y\")\; .$commentDetails.=\"<br/><br/><p>.$comment.</p><h4>.$commentauthor. @ .$commenttime.</h4><br/>\"\; fwrite(.$addComment.,.$commentDetails.)\; fclose(.$addComment.)\; echo \"Your comment has been added. Please refresh this page to see it.<br/><br/>\"; } ?> <!-- comment form --><form action=\".$label..php\" method=\"post\"><strong>Comment:</strong><br/><input type=\"text\" name=\"comment\" value=\"\"/><br/><strong>Author:</strong><br/><input type=\"text\" name=\"commentauthor\" value=\"\"/><br/><br/><input type=\"submit\" name=\"commentsubmit\" value=\"Submit\"/></form></body></html>";

:shrug:

 

.$showComment.=fread(.$readComment.,filesize(.$commentFile.))\; fclose($readComment)\; echo .$showComment.\; if(isset($_POST[\'commentsubmit\'])){ .$addComment.=fopen(.$commentFile.,\'a\')\; .$comment.=$_POST[\'comment\']\; .$commentauthor.=$_POST[\'commentauthor\']\; .$commenttime.=date(\"g:i a M j, Y\")\; .$commentDetails.=\"<br/><br/><p>.$comment.</p><h4>.$commentauthor. @ .$commenttime.</h4><br/>\"\; fwrite(.$addComment.,.$commentDetails.)\; fclose(.$addComment.)\; echo \"Your comment has been added. Please refresh this page to see it.<br/><br/>\"; } ?> <!-- comment form --><form action=\".$label..php\" method=\"post\"><strong>Comment:</strong><br/><input type=\"text\" name=\"comment\" value=\"\"/><br/><strong>Author:</strong><br/><input type=\"text\" name=\"commentauthor\" value=\"\"/><br/><br/><input type=\"submit\" name=\"commentsubmit\" value=\"Submit\"/></form></body></html>";

 

What is this ?.

The best thing for you to do is re-write, putting the code on 'more than one line'

 

It would of made the error easier to spot( line numbers are given on errors)

 

The code would be a nightmare for you to maintain later on...

 

But a quick look suggests theres missing quotes all over the show and some that havent be slashed out...

 

So i suggest re-write  :D (im sure you really dont want to tho)

Thats a php script that I want to written to the new file to allow visitors to comment on it.

 

You seem to missing the basic concepts of a dynamic web application. Do you think every time someone makes a new thread on this forum a new script is created so we can reply to it?

No, because I'm sure the forum uses databases :P but I don't know how to and only want a simple code for my assignment as we haven't been taught how to use databases yet, simply how to write to files etc.

 

I put it all on one line because in notepad++ when I put it on multiple lines it regained its colour instead of staying grey. If I can put it on multiple lines and still write it to a file then I'll do that.

Here's the commenting code on multiple lines, do i simply need to make sure all quotes are slashed out or must I do more to it?

 

 

<?php 
/* shows previously published comments */
$commentFile=\"blog/$label.txt\";
$readComment=fopen($commentFile,\'r\');
$showComment=fread($readComment,filesize($commentFile));
fclose($readComment);
echo $showComment;

/* creates new comment from form */
if(isset($_POST[\'submit\'])){
	$addComment=fopen($commentFile,\'a\');
	$comment=$_POST[\'comment\'];		
	$author=$_POST[\'author\'];
	$time=date(\"g:i a M j, Y\");
	$commentDetails=\"<br/><br/><p>$comment</p><h4>$author @ $time</h4><br/>\";
	fwrite($addComment,$commentDetails);
	fclose($addComment);
	echo \"Your comment has been added. Please refresh this page to see it.<br/><br/>\";
}		
?>
<!-- comment form -->
<form action=\"test2.php\" method=\"post\">
<strong>Comment:</strong><br/>
<input type=\"text\" name=\"comment\" value=\"\"/><br/>
<strong>Author:</strong><br/>
<input type=\"text\" name=\"author\" value=\"\"/><br/><br/>
<input type=\"submit\" name=\"submit\" value=\"Submit\"/>
</form>

This is the bug free code for you. but I advice you must learn HTML and PHP

 

;) Njoy

 

<?php 

if(isset($_POST['submit'])){	

/* shows previously published comments */



$commentFile= "blog/$label.txt";



$readComment=fopen($commentFile,'r');



$showComment=fread($readComment,filesize($commentFile));



fclose($readComment);



echo $showComment;






/* creates new comment from form */







$addComment=fopen($commentFile,'a');





$comment=$_POST['comment'];










$author=$_POST['author'];





$time=date("g:i a M j, Y");





$commentDetails="<br/><br/><p>$comment</p><h4>$author @ $time</h4><br/>";





fwrite($addComment,$commentDetails);





fclose($addComment);





echo "Your comment has been added. Please refresh this page to see it.<br/><br/>";



}






?>
<!-- comment form -->
<form action="test2.php" method="post">
<strong>Comment:</strong><br/>
<input type="text" name="comment" value=""><br/>
<strong>Author:</strong><br/>
<input type="text" name="author" value=""><br/><br/>
<input type="submit" name="submit" value="Submit"/>
</form>

Thanks for trying to help, but thats not what I want. I know HTML and I know basic php, and I already had a working comment code, I was simply trying to write it to each file that I create with another php code, basically a blog system and each article can be commented on.

 

I have working codes, just not when I try to put one inside the other.

This code is working (TESTED) if you submit it correctly

 

currently its

 

<form action="test2.php" method="post">

 

if you have this code on test2.php then It will work fine.

 

<form action="yourfile.php" method="post">

>.<;; I suck at explaining things.

 

Here's the basics:

 

I have a file named write.php. This file contains code that allows one to publish an article to a new file, created when they sumbit the form. This code also creates a link in a file called link.txt

 

I then have a file called read.php. This file opens link.txt, reads its list of links and then echos them onto the screen. Each of these links leads to a seperate page with a seperate article.

 

I have created a working code that allows visitors to these articles to comment, however I have not been able to implement it on the seperate pages. What I want to do, is when I create a new page for a new article, is to include the comment php so that when I go to the page with the article on it, ican post and read comments. My attempt to do this through the variable $blog came up with the expecting a 'T_string' parse error.

 

Is there anyway that I can insert the php into each new page as they are created?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.