I am trying to use file_put_contents for the first time and I have an issue that is driving me crazy. The file is being written, but not all of the content is getting written. This could be convoluted but, here goes:
I am trying to create an HTML email confirmation of an order form a client portal. In the function to create the message body and write it to a file for Mime_mail to call I have a variable that is assigned this string:
html headers
stylesheet
body text
and here I want to insert dynamic html in a table from the order details
so -> query the database
use the results to put data in the variables in the TD
I have this in a separate function, one for the delivery details and one function for the items.
then write some more body text
close the html
call file_put_contents (path/name, filedata)
When I look at the file that was output, the static portion of the string is there along with a couple of variables (name, csr_name), but the dynamic stuff is not. The kicker is that the dynamic stuff is being output to my success page, but I did not call for it to be output (yet).
So far I have tried:
$file_data = 'html string of stuff';
$file_data .= function($arg);
$file_data .= 'html string stuff to end';
and
$function_res = function($arg);
$file_data = 'html string of stuff';
$file_data .= $function_res;
$file_data .= 'html string stuff to end';
The functions are a basic query database, return an array of results, parse the array and write the desired data to an html table with echo statements.
The user has reviewed the order and clicked to confirm, redirects to the success page where there is some cart cleanup, call to the mail_message function, which has the create_message function which calls the dynamic content functions and output the success message (static) where it would also display the order details (not written into the script yet).
Any thoughts and pointers are appreciated. I can expound on the code as requested. I just did not want this to turn into a novella.