Paul Ferrie wrote:

Title i am sure i will get sorted. The main issue is passing the php var to the js script. so that the text area is populated with the relevent article

I am not sure, have you tried something as simple as this:

<script language="JavaScript" type="text/javascript">
<textarea name="news"><?php echo $arNews; ?></textarea>
</script> 

Also, have you tried to echo out the vaule elsewhere on the page to know it is not empty?

    Rodney H. i know that the var is being passed ok because arTitle is pulled from the same query.
    I dont know how the JS worsk. It's a rich text editor i got off hotscripts.com

      I was looking on dynamic dive web site where you possibly downloaded this, and looked at the source code for the demo. I thought maybe you have a single quote in your string before any output, so, Try this:

      writeRichText('rte1', '<?php 
      
      echo htmlentities($arNews, ENT_QUOTES); // maybe this will help
      
      ?>', 500, 200, true, false); 

        It's seems that the data is loading fine acordding to view source. There seems to be some kind of conflict happening but it is behound me.

        data being puled from the db does contain html tags

          Have you tried stripping all the tags with PHP before entering it? (just out of curiousity)

            No that would defeat the purpose of what i am trying to do.

              My next question is.

              Is it possible to right an hmtl page or update an exsisting html page on there server were as before i would just update the database.

              Thanks

                Certainly, you'd just write the HTML into a file instead of into a database. There's nothing in this code that stops you from doing anything you want with the submitted HTML or stops you from getting it from wherever you've got it.

                  How do i go about creating the html page and saving or over-writing an existing page?
                  It's somethimg i have never had to do.

                  thanks
                  Paul

                    I think you could use fopen and fwrite in this case to overwrite the file's contents:

                    <?php
                    // select file
                    $file = 'YourFileName.php';
                    
                    // select info to update file with as variable
                    $string = $updated_html_file; 
                    
                    // If file exists and is writable
                    if (is_writable($file)){
                    
                    // Open $file in write mode or exit
                    if (!$handle = fopen($file, 'w')){
                    echo 'Cannot open file ('.$file.').';
                    exit;
                    }
                    
                    // Write $string to our opened file or exit
                    if (fwrite($handle, $string) === FALSE){
                    echo 'Cannot write to file ('.$file.').';
                    exit;
                    }
                    
                    echo 'Success. The file, '.$file.', was appended with '.$string.'.';
                    // close file handle
                    fclose($handle);
                    }
                    
                    else {
                    echo 'The file '.$file.' is not writable.';
                    }
                    ?>

                      Paul, make sure you open the file in 'w' mode (overwrite) rather than 'a' (apend) to completely overwrite the file with the new contents. I edited the code above....

                      :- )

                        Thanks.

                        If the file does not exsist will it be created?

                          [man]fopen[/man]

                          Table 1. A list of possible modes for fopen() using mode
                          mode Description
                          'w' Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.

                            Something is wrong somewhere. The files is created if it does not exsist but if the file does exsist then it adds to the contents of the fileπŸ™

                            Can you see where i am going wrong:

                            $file = "../../jcb/".$_POST['arTitle'].".htm"; 
                            // select info to update file with as variable 
                            $string = $updated_html_file;  
                            // If file does not exist create and make writeable if (!is_writable($file)){ $handle = fopen($file, 'w+'); if (fwrite($handle, $string) === FALSE){ echo 'Cannot write to file ('.$file.').'; exit; } echo 'Success. The file, '.$file.', was created.'; // close file handle fclose($handle); }else{ $handle = fopen($file, 'w'); if (fwrite($handle, $string) === FALSE){ echo 'Cannot write to file ('.$file.').'; exit; } echo 'Success. The file, '.$file.', was appended.'; // close file handle fclose($handle); }

                            Thanks

                              You will need file functions in php. These should get you started and sorted out:

                              quick to do tut.

                              [MAN]fopen[/MAN]
                              [MAN]fwrite[/MAN]
                              [MAN]file_exists[/MAN]
                              [MAN]is_writable[/MAN]

                                Paul Ferrie wrote:
                                // If file does not exist create and make writeable
                                if (!is_writable($file)){ 
                                	// do stuff
                                } 
                                

                                I think you mean to do this:

                                // If file does not exist...
                                if (!file_exists($file)){ 
                                	// do stuff
                                } 
                                
                                  Write a Reply...