morocco-iceberg Posted March 23, 2010 Share Posted March 23, 2010 Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in C:\wamp\www\write.php on line 25 I don't understand what this means... Quote Link to comment https://forums.phpfreaks.com/topic/196224-help-what-does-this-mean-expecting-t_string/ Share on other sites More sharing options...
Wolphie Posted March 23, 2010 Share Posted March 23, 2010 Please post the line of code where the error is. Quote Link to comment https://forums.phpfreaks.com/topic/196224-help-what-does-this-mean-expecting-t_string/#findComment-1030455 Share on other sites More sharing options...
trq Posted March 23, 2010 Share Posted March 23, 2010 It means what it says. PHP was expecting a certain token and found something else. Its the number one sign there is a syntax error in your code. Quote Link to comment https://forums.phpfreaks.com/topic/196224-help-what-does-this-mean-expecting-t_string/#findComment-1030456 Share on other sites More sharing options...
inversesoft123 Posted March 23, 2010 Share Posted March 23, 2010 use single quotes 'like this', not ‘directional quotes’ Quote Link to comment https://forums.phpfreaks.com/topic/196224-help-what-does-this-mean-expecting-t_string/#findComment-1030457 Share on other sites More sharing options...
morocco-iceberg Posted March 23, 2010 Author Share Posted March 23, 2010 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>"; Quote Link to comment https://forums.phpfreaks.com/topic/196224-help-what-does-this-mean-expecting-t_string/#findComment-1030464 Share on other sites More sharing options...
trq Posted March 23, 2010 Share Posted March 23, 2010 All on one line? Your kidding. Quote Link to comment https://forums.phpfreaks.com/topic/196224-help-what-does-this-mean-expecting-t_string/#findComment-1030467 Share on other sites More sharing options...
maca134 Posted March 23, 2010 Share Posted March 23, 2010 lol Quote Link to comment https://forums.phpfreaks.com/topic/196224-help-what-does-this-mean-expecting-t_string/#findComment-1030468 Share on other sites More sharing options...
inversesoft123 Posted March 23, 2010 Share Posted March 23, 2010 lol.. is this a variable ? blog = or $blog = ? Quote Link to comment https://forums.phpfreaks.com/topic/196224-help-what-does-this-mean-expecting-t_string/#findComment-1030469 Share on other sites More sharing options...
morocco-iceberg Posted March 23, 2010 Author Share Posted March 23, 2010 Yeah its a variable, the $ didn't copy over. Quote Link to comment https://forums.phpfreaks.com/topic/196224-help-what-does-this-mean-expecting-t_string/#findComment-1030471 Share on other sites More sharing options...
inversesoft123 Posted March 23, 2010 Share Posted March 23, 2010 .$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 ?. Quote Link to comment https://forums.phpfreaks.com/topic/196224-help-what-does-this-mean-expecting-t_string/#findComment-1030476 Share on other sites More sharing options...
morocco-iceberg Posted March 23, 2010 Author Share Posted March 23, 2010 Thats a php script that I want written to the new file to allow visitors to comment on it. Quote Link to comment https://forums.phpfreaks.com/topic/196224-help-what-does-this-mean-expecting-t_string/#findComment-1030478 Share on other sites More sharing options...
maca134 Posted March 23, 2010 Share Posted March 23, 2010 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 (im sure you really dont want to tho) Quote Link to comment https://forums.phpfreaks.com/topic/196224-help-what-does-this-mean-expecting-t_string/#findComment-1030480 Share on other sites More sharing options...
trq Posted March 23, 2010 Share Posted March 23, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/196224-help-what-does-this-mean-expecting-t_string/#findComment-1030481 Share on other sites More sharing options...
morocco-iceberg Posted March 23, 2010 Author Share Posted March 23, 2010 No, because I'm sure the forum uses databases 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. Quote Link to comment https://forums.phpfreaks.com/topic/196224-help-what-does-this-mean-expecting-t_string/#findComment-1030484 Share on other sites More sharing options...
morocco-iceberg Posted March 23, 2010 Author Share Posted March 23, 2010 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> Quote Link to comment https://forums.phpfreaks.com/topic/196224-help-what-does-this-mean-expecting-t_string/#findComment-1030486 Share on other sites More sharing options...
morocco-iceberg Posted March 23, 2010 Author Share Posted March 23, 2010 Obviously I have no idea what I'm doing... Quote Link to comment https://forums.phpfreaks.com/topic/196224-help-what-does-this-mean-expecting-t_string/#findComment-1030492 Share on other sites More sharing options...
inversesoft123 Posted March 23, 2010 Share Posted March 23, 2010 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> Quote Link to comment https://forums.phpfreaks.com/topic/196224-help-what-does-this-mean-expecting-t_string/#findComment-1030494 Share on other sites More sharing options...
morocco-iceberg Posted March 23, 2010 Author Share Posted March 23, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/196224-help-what-does-this-mean-expecting-t_string/#findComment-1030499 Share on other sites More sharing options...
inversesoft123 Posted March 23, 2010 Share Posted March 23, 2010 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"> Quote Link to comment https://forums.phpfreaks.com/topic/196224-help-what-does-this-mean-expecting-t_string/#findComment-1030502 Share on other sites More sharing options...
morocco-iceberg Posted March 23, 2010 Author Share Posted March 23, 2010 >.<;; 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? Quote Link to comment https://forums.phpfreaks.com/topic/196224-help-what-does-this-mean-expecting-t_string/#findComment-1030508 Share on other sites More sharing options...
morocco-iceberg Posted March 23, 2010 Author Share Posted March 23, 2010 The code links to test2.php because I copied the multi-line code from that file. The code will be required to work on whiever new page is created, so I've used the variable $label.php in the action part of the form. Quote Link to comment https://forums.phpfreaks.com/topic/196224-help-what-does-this-mean-expecting-t_string/#findComment-1030510 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.