Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<?php
	// create short variable name
		$document_root = $_SERVER['DOCUMENT_ROOT'];
	?>
<html>
	<head>
		<title>Yudz Tech - Order Results</title>
	</head>
	<body>
		<h1>Yudz Technology</h1>
		<h2>Customer Orders</h2>
		<?php 
			@ $fp = fopen("orders.txt", 'rb');
			flock($fp, LOCK_SH); // lock file for reading
			
			if (!$fp){
				echo"<p>No orders pending.
				Please try again later.</p>";
				exit;
			}
			
			while(!feof($fp)){
			$order = fgets($fp);
			echo htmlspecialchars($order)."<br />;
			}
			
			flock($fp, LOCK_UN); //release read lock
			fclose($fp);
			
		?>
	</body>
</html>


What I have tried:

ok i've change my code, added closing . now it shows this

Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\yudztech\vieworders.php on line 32
Posted
Updated 13-Jan-18 0:12am
v3
Comments
ThilinaMD 13-Jan-18 2:19am    
first examine for open and close of brackets,{ } and <?php , ?> tags
Member 13620887 13-Jan-18 6:13am    
yes i examined them all and it's complete.
David_Wimbley 13-Jan-18 2:24am    
When i post your code into notepad it only has 30 lines so my first suggestion would be to post the first actual 32 lines of your code (or say 40 lines) instead of this snippet. All this is is a guessing game for us. If we can see the line that specifies the error.

My other suggestion is to remove your @ signs. I'm a bit rusty on my PHP but i believe those are to supress any error messages. By supressing error messages all you are doing is kicking the can down the road a bit further and causing yourself more headaches as the "error" is triggering as a false positive.

Remove your @ signs and then retry your code.
Peter_in_2780 13-Jan-18 2:28am    
In this case, it seems his @ is legit. It's a common idiom to try to open a file then treat the failure case as "non-existent file".
Peter_in_2780 13-Jan-18 2:26am    
It's hard to tell with your code unformatted, but the usual cause of this error is that there is something unterminated. It could be a simple as a quoted string, or a {...} block. The interpreter is looking for the end of a "something" to pick up the next "something", but it fell off the end of your file before it found it.
Please edit your question, put your code in a "code block", selecting PHP as the language.

PHP
echo htmlspecialchars($order)."<br>;

Are you sure this line doesn't need a second quote?

Advice: check resulting hrml, the endding tag is missing.
HTML
<title>Yudz Tech - Order Results
 
Share this answer
 
<?php
	// create short variable name
		$document_root = $_SERVER['DOCUMENT_ROOT'];
	?>

	
		<title>Yudz Tech - Order Results</title>
	
	
		<h1>Yudz Technology</h1>
		<h2>Customer Orders</h2>
		<?php 
			@ $fp = fopen("orders.txt", 'rb');
			flock($fp, LOCK_SH); // lock file for reading
			
			if (!$fp){
				echo"<p>No orders pending.
				Please try again later.</p>";
				exit;
			}
			
			while(!feof($fp)){
			$order = fgets($fp);
			echo htmlspecialchars($order)."<br>;
			}
			
			flock($fp, LOCK_UN); //release read lock
			fclose($fp);
			
		?>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900