morocco-iceberg Posted July 8, 2010 Share Posted July 8, 2010 I keep getting this error: Parse error: parse error in * on line 4712 (which is the last line in the file and only contains ?>). I can't find anything wrong, and as the error doesn't specify anything I don't know what kind of error to look for. Does anyone know what this would typically be reffering to? Quote Link to comment https://forums.phpfreaks.com/topic/207102-parse-error-at-end-of-file-with-no-description/ Share on other sites More sharing options...
BillyBoB Posted July 8, 2010 Share Posted July 8, 2010 without the code i wouldn't know but it looks like there is quite a bit of code Quote Link to comment https://forums.phpfreaks.com/topic/207102-parse-error-at-end-of-file-with-no-description/#findComment-1082877 Share on other sites More sharing options...
trq Posted July 8, 2010 Share Posted July 8, 2010 Its likely a curly brace or something, we would need to see some code to help though. Quote Link to comment https://forums.phpfreaks.com/topic/207102-parse-error-at-end-of-file-with-no-description/#findComment-1082878 Share on other sites More sharing options...
morocco-iceberg Posted July 8, 2010 Author Share Posted July 8, 2010 Here's the lines near the end of the file that I suspect the error is located, but I suppose it could be anywhere. <h1>Opposites</h1>" .$oppo."<br/><br/>"; oppo("oppoe"); oppo("oppop"); oppo("oppoi"); oppo("oppou"); oppo("oppoa"); $oppoAnswers = array($oppoe_a0, $oppoe_a1, $oppop_a0, $oppop_a1, $oppoi_a0, $oppoi_a1, $oppou_a0, $oppou_a1, $oppoa_a0, $oppoa_a1); shuffle($oppoAnswers); echo "<table border=\"1\" bordercolor=\"#000000\" rules=\"none\" frame=\"box\" cellpadding=\"5\"> <tr> <td>".$oppoAnswers[0]."</td> <td>".$oppoAnswers[1]."</td> <td>".$oppoAnswers[2]."</td> <td>".$oppoAnswers[3]."</td> <td>".$oppoAnswers[4]."</td> </tr> <tr> <td>".$oppoAnswers[5]."</td> <td>".$oppoAnswers[6]."</td> <td>".$oppoAnswers[7]."</td> <td>".$oppoAnswers[8]."</td> <td>".$oppoAnswers[9]."</td> </tr> </table> <table>"; $oppoOptions = array($oppoe_0, $oppoe_1, $oppop_0, $oppop_1, $oppoi_0, $oppoi_1, $oppou_0, $oppou_1, $oppoa_0, $oppoa_1); shuffle($oppoOptions); $oppoSelect = $oppoOptions[0].$oppoOptions[1].$oppoOptions[2].$oppoOptions[3].$oppoOptions[4].$oppoOptions[5].$oppoOptions[6].$oppoOptions[7].$oppoOptions[8].$oppoOptions[9]; echo $oppoe_s; echo $oppoSelect; echo $oppoe_m; echo $oppoSelect; echo $oppoe_e; echo $oppop_s; echo $oppoSelect; echo $oppop_m; echo $oppoSelect; echo $oppop_e; echo $oppoi_s; echo $oppoSelect; echo $oppoi_m; echo $oppoSelect; echo $oppoi_e; echo $oppou_s; echo $oppoSelect; echo $oppou_m; echo $oppoSelect; echo $oppou_e; echo $oppoa_s; echo $oppoSelect; echo $oppoa_m; echo $oppoSelect; echo $oppoa_e; echo "</table> <div id=\"center\"><input type=\"submit\" value=\"Move to next section...\" onClick=\"return confirm('Are you sure you want to move to the next section?');\" /></div> </form> </body> </html>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/207102-parse-error-at-end-of-file-with-no-description/#findComment-1082880 Share on other sites More sharing options...
BillyBoB Posted July 8, 2010 Share Posted July 8, 2010 you would have to search the whole code.... Quote Link to comment https://forums.phpfreaks.com/topic/207102-parse-error-at-end-of-file-with-no-description/#findComment-1082882 Share on other sites More sharing options...
PFMaBiSmAd Posted July 8, 2010 Share Posted July 8, 2010 Nope. That block of code does not produce a parse error (after you eliminate the first few lines that were part of a previous string.) A) I don't know what anyone would be doing putting 4000+ lines of code in one file. B) Before you attempt to work on a project that was made up of that many total lines of code, you need to develop some modular programming and organizational skills. Breaking a large project into smaller pieces would also allow you to test each individual section and you would not be faced with a - "my 4000+ line file contains a parse error and I cannot find it." Quote Link to comment https://forums.phpfreaks.com/topic/207102-parse-error-at-end-of-file-with-no-description/#findComment-1082884 Share on other sites More sharing options...
trq Posted July 8, 2010 Share Posted July 8, 2010 These lines look suspect. oppo("oppoe"); oppo("oppop"); oppo("oppoi"); oppo("oppou"); oppo("oppoa"); Quote Link to comment https://forums.phpfreaks.com/topic/207102-parse-error-at-end-of-file-with-no-description/#findComment-1082886 Share on other sites More sharing options...
morocco-iceberg Posted July 8, 2010 Author Share Posted July 8, 2010 Yeah, I haven't really developed the whole organizational skills thing yet, I've just started my database design course at uni, and am obviously still learning. I've only been coding php and mysql for about a month now. Most of the lines of code are part of a function that I couldn't figure out how to do any other way. The oppo("oppop"); lines call to a previous function, and the text within the "" is the name of the table contained in the database that the function uses. Quote Link to comment https://forums.phpfreaks.com/topic/207102-parse-error-at-end-of-file-with-no-description/#findComment-1082888 Share on other sites More sharing options...
PFMaBiSmAd Posted July 8, 2010 Share Posted July 8, 2010 LOL, all that code looks suspect (it's repetitious, hard-coded, nondescript variable names...) Quote Link to comment https://forums.phpfreaks.com/topic/207102-parse-error-at-end-of-file-with-no-description/#findComment-1082889 Share on other sites More sharing options...
PFMaBiSmAd Posted July 8, 2010 Share Posted July 8, 2010 You must have some idea what you changed in the code at the point in time it went from parsing without any errors to the present error? Quote Link to comment https://forums.phpfreaks.com/topic/207102-parse-error-at-end-of-file-with-no-description/#findComment-1082890 Share on other sites More sharing options...
morocco-iceberg Posted July 8, 2010 Author Share Posted July 8, 2010 LOL, all that code looks suspect (it's repetitious, hard-coded, nondescript variable names...) Lol, yeah, like I said I'm still learning so I've probably done it all the worst way. And the names are descriptive to me, i.e oppop calls to the table that contains the opposites pre-intermediate questions. And any tips how could I make it less repetitive? I did it this way because that's all I thought I could do... I fixed something and now the parse error is apparently on line 136... which I can't find, it seriously just skips from 134 to 139, without a tab to expand it or anything. Quote Link to comment https://forums.phpfreaks.com/topic/207102-parse-error-at-end-of-file-with-no-description/#findComment-1082891 Share on other sites More sharing options...
PFMaBiSmAd Posted July 8, 2010 Share Posted July 8, 2010 All you likely did was to create a more serious syntax error earlier in the file and it isn't even reaching the point that was causing your original error. Quote Link to comment https://forums.phpfreaks.com/topic/207102-parse-error-at-end-of-file-with-no-description/#findComment-1082892 Share on other sites More sharing options...
morocco-iceberg Posted July 8, 2010 Author Share Posted July 8, 2010 Ok, well I'll go through and try to rewrite the code in a better way, thanks for all of the help. And, yes I'm stupid, but what does 'hard code' mean? I googled it and can't find any definitions... Quote Link to comment https://forums.phpfreaks.com/topic/207102-parse-error-at-end-of-file-with-no-description/#findComment-1082893 Share on other sites More sharing options...
PFMaBiSmAd Posted July 8, 2010 Share Posted July 8, 2010 Hard-coding something means to write line after line of same/similar code that only differs in value or name and then you must edit that list of code in order to add or change anything, instead of factoring out the common processing and using a loop to accomplish the same thing. An example would be producing a form and processing the form data. Instead of writing out all the lines of the form (hard-coding the form), you could use an array to define the form fields and then simply use a loop to produce the form and then use a similar loop when validating and processing the form data. Here is one example where probably a couple of hundreds of lines of code was reduced to a couple of tens of lines of code - http://www.phpfreaks.com/forums/index.php/topic,303004.msg1433644.html#msg1433644 Quote Link to comment https://forums.phpfreaks.com/topic/207102-parse-error-at-end-of-file-with-no-description/#findComment-1082894 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.