Click here to Skip to main content
13,762,431 members
Rate this:
 
Please Sign up or sign in to vote.
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 12-Jan-18 20:52pm
Updated 13-Jan-18 1: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.
Richard MacCutchan 13-Jan-18 4:47am
   
Your <title> tag is not terminated.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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

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

Advice: check resulting hrml, the endding tag is missing.
<title>Yudz Tech - Order Results
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

<?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);
			
		?>
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web06-2016 | 2.8.181111.1 | Last Updated 13 Jan 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100