Jump to content

Parse error at end of file with no description?


Recommended Posts

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?

Link to comment
Share on other sites

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>";
?>

Link to comment
Share on other sites

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."

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.