Jump to content

Issue reading text files.


rambothefirst

Recommended Posts

Hello all,

 

Really need help with this I have been working on it for a few days, but no luck getting it to work. I am trying to get the file from the server location and place it into a text-box with an editor installed. My first php $file shows the location I need if I echo it, but when I place it all together and try to use js to echo $string its not displaying the text from the file.

<?php$f = $_SERVER['DOCUMENT_ROOT'] . "/files/<?php echo safeOutputToScreen($file->localFilePath, null, 55); ?>";$contents = file($f);$string = implode($contents);echo $string;?> <form><textarea  id="editor1" name="editor1"></textarea></form><script>CKEDITOR.replace( 'editor1' );</script><script>document.getElementById('editor1').defaultValue="<?php echo $string ?>";</script></div></div></div></body><? include('_footer.php'); ?><?php end() ?> 
Link to comment
Share on other sites

 

  1. <script>document.getElementById('editor1').defaultValue="<?php echo $string ?>";</script>

echo is missing ;

<?php echo $string; ?>

 

Sorry my fault it don't work with ; it is just not there because I was copy & pasting. I have tried echo in many different ways. I can also get it to output in the textbox, /files/<?php echo safeOutputToScreen($file->localFilePath, null, 55); ?> it just don’t seem to notice the php and place it as a string.

Link to comment
Share on other sites

This line is a problem because you're already inside a <?php ?> block:

$f = $_SERVER['DOCUMENT_ROOT'] . "/files/<?php echo safeOutputToScreen($file->localFilePath, null, 55); ?>";

Substitute it with

$f = $_SERVER['DOCUMENT_ROOT'] . "/files/" . safeOutputToScreen($file->localFilePath, null, 55);

It might not be the only problem, but it's best to start with the most obvious thing to fix.

Link to comment
Share on other sites

This line is a problem because you're already inside a <?php ?> block:

$f = $_SERVER['DOCUMENT_ROOT'] . "/files/<?php echo safeOutputToScreen($file->localFilePath, null, 55); ?>";

Substitute it with

$f = $_SERVER['DOCUMENT_ROOT'] . "/files/" . safeOutputToScreen($file->localFilePath, null, 55);

It might not be the only problem, but it's best to start with the most obvious thing to fix.

 

Thanks Foxy Mod I have it working now.

 

Is it possible with PHP to open the text file and edit it in textbox and auto save in the same text file.?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...