olie480 Posted September 8, 2009 Share Posted September 8, 2009 Hello Freaks!! I have a question that has been boggling my mind for sometime, but never looked into it. Basically what I have been doing is trying to send HTML info through a variable, but everytime I do it, I have to select the HTML and do a FIND: " & REPLACE WITH: \" in Dreamweaver. It was fun in the beginning, but now it seems to be a pain, and wish to just do a simple include("../htmlinfo.php"); But when I do that of course, the variables that I am trying to pass through do not get executed. I am basically doing this for HTML Email and stuff. So to recap, I want to turn this: <?php $content = "<head> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /> <title>Untitled Document</title> </head> <body> <table width=\"654\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td>CONTACT</td> <td> </td> </tr> <tr> <td align=\"right\">Name:</td> <td> </td> </tr> <tr> <td align=\"right\">Number:</td> <td> </td> </tr> <tr> <td align=\"right\">Email:</td> <td> </td> </tr> <tr> <td align=\"right\">City:</td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> </table> </body> </html>"; ?> TO THIS: <?php $content = include("../htmlform.inc.php"); ?> The reason why I want to make this simple is because if I change something in the HTML, I have to repaste the code, and do the FIND and REPLACE method again. Just does not seem too efficient. Any suggestions? Thank you! Olie Quote Link to comment https://forums.phpfreaks.com/topic/173578-html-in-php/ Share on other sites More sharing options...
mikesta707 Posted September 8, 2009 Share Posted September 8, 2009 just storing the value in a variable won't echo it out. What does your include page look like? if it looks like the first php you posted, don't assign the variable, just write the code, and when you include it the code will be executed. Quote Link to comment https://forums.phpfreaks.com/topic/173578-html-in-php/#findComment-914935 Share on other sites More sharing options...
olie480 Posted September 8, 2009 Author Share Posted September 8, 2009 just storing the value in a variable won't echo it out. What does your include page look like? if it looks like the first php you posted, don't assign the variable, just write the code, and when you include it the code will be executed. Well basically I am just using the $content variable to send out a HTML email, which is why I am using the FIND & REPLACE method. I can't seem to find another way to pass it through to email to everyone. So I would use it as: <?php mail("olie@whatever.com", $subject, $content); ?> But whenever I use the <?php $content = include("../html.inc.php"); ?> The only thing that shows up in the email is the number 1 I should also let you know that I am setting this up because variable data is being sent from MySql to input into the HTML portion... Like "Hello Mike!... yadda yadda yadda..." Quote Link to comment https://forums.phpfreaks.com/topic/173578-html-in-php/#findComment-914973 Share on other sites More sharing options...
TeNDoLLA Posted September 8, 2009 Share Posted September 8, 2009 That is because the include() -function does not return the file contents, it returns 1 if the include was succesful. You must use other file reading functions to read the file in to variable and then use this variable in the email. For example file_get_contents() could do it(?). Quote Link to comment https://forums.phpfreaks.com/topic/173578-html-in-php/#findComment-914978 Share on other sites More sharing options...
mikesta707 Posted September 8, 2009 Share Posted September 8, 2009 Ahh i see your problem. Yes the function you want to use is file_get_contents as tendolla has said. Quote Link to comment https://forums.phpfreaks.com/topic/173578-html-in-php/#findComment-914982 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.