2 Replies - 672 Views - Last Post: 11 October 2009 - 03:25 PM Rate Topic: -----

#1 fortesque  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 02-June 09

Output Buffering Control error/parse error

Post icon  Posted 11 October 2009 - 09:11 AM

Hello:
I have a script (save_html_output_1.php) that requires a file ("patient_query_last_insert_KCP.php")The file
1. accesses a mysql table
2.processes the data with a series of algorithms
3.writes the output in html table format.
This file "patient_query_last_insert_KCP.php" works ok when manually loaded through IE.
However, when I run the script "save_html_output_1" the following error message occurs:

Parse error: syntax error, unexpected $end in /homepages/21/d157913018/htdocs/abis/practice/save_html_output_1.php on line 10


I want to automate the steps of accessing file "patient_query_last_insert_KCP.php", saving the results and emailing them.
As a first step I have a smalll script (save_html_output_1.php) to run file ("patient_query_last_insert_KCP.php") and save it for later use. I found the "save_html_output_1.php" script on a forum after considerable search. The author claims to have tested the script and said it works.

Searches I have made turn up suggestions about not using short form of php call, that is using full php declaration<?php and ?>. That does not seem to be the problem.
Ideas about how to correct this problem much appreciated.

Thanks,
JWB



<?php
ob_start();
	require_once('http://www.headacheanalysis.com/patient_query_lastinsert_KPC.php');
	$output = ob_get_contents();
// Print the test result;
print $output;
// Save the test result to a file
file_put_contents("C:\Users\John\Documents\", $output);
 ob_end_clean();
?>



Is This A Good Question/Topic? 0
  • +

Replies To: Output Buffering Control error/parse error

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4187
  • View blog
  • Posts: 11,851
  • Joined: 18-April 07

Re: Output Buffering Control error/parse error

Posted 11 October 2009 - 09:36 AM

Well first of all, you are getting the unexpected $end error here because you don't specify an actual output filename. You just have a path. Secondly, keep in mind that file_get_contents() puts a file on the remote server, so the directory has to exist. Kinda looks like you might be trying to do a local path.

Third, make sure you have URL fopen wrappers setting enabled or you won't be able to use URLs in a require_once function (you really shouldn't require functions from remote servers anyways, but that is a security technicality I won't go into here).

So check these problems out and see if they help you out. :)
Was This Post Helpful? 1
  • +
  • -

#3 fortesque  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 02-June 09

Re: Output Buffering Control error/parse error

Posted 11 October 2009 - 03:25 PM

View PostMartyr2, on 11 Oct, 2009 - 08:36 AM, said:

Well first of all, you are getting the unexpected $end error here because you don't specify an actual output filename. You just have a path. Secondly, keep in mind that file_get_contents() puts a file on the remote server, so the directory has to exist. Kinda looks like you might be trying to do a local path.

Third, make sure you have URL fopen wrappers setting enabled or you won't be able to use URLs in a require_once function (you really shouldn't require functions from remote servers anyways, but that is a security technicality I won't go into here).

So check these problems out and see if they help you out. :)

Martyr2:
Thanks for your reply. Making progress with this problem. Now have to figure out how to get past Fatal error: Call to undefined function: file_put_contents(). I'll search PHP cookbook and other materials for an answer. Here's the new code that at least gets a 'w' file written to the server, although of course it has no content.
<?php
ob_start();
	require_once('http://www.headacheanalysis.com/patient_query_lastinsert_KPC.php');
	$output = ob_get_contents();

// Save the test result to a file
$fn = "save_test.txt";
$fh = fopen($fn, 'w') or die("can't open file");


$mytest = file_put_contents($fn,$output);
print $mytest;
fclose($fh);
 ob_end_clean();
?>


Can you say more about your comment:
"Third, make sure you have URL fopen wrappers setting enabled or you won't be able to use URLs in a require_once function (you really shouldn't require functions from remote servers anyways, but that is a security technicality I won't go into here)." Particularly interested in point that shouldn't require functions from remote servers.
Thanks,
JWB
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1