mrdee
Oct 24 2008, 07:29 PM
| | I have a funny problem when I embed PHP in a HTML page whenever I write some PHP code with the 'print' or 'echo' command, the output shows the end bits of the PHP code, eg. when I write:
CODE <?php print "This is PHP"; ?> the output I get is:
This is PHP";?>
So, the final quote mark, the semicolon and the ending PHP tags are displayed. Has anyone else come across this problem before, and does anyone know a solution for it?
By the way, the full code would be:
CODE <html> <head> </head> <body> Some HTML <?php print "This is PHP"; ?> </body> </html> The funny thing is, this does not happen when I do a PHP only page.
All help will be appreciated. |
Comment/Reply (w/o sign-up)
jlhaslip
Oct 25 2008, 01:26 AM
Is the file saved as a php or an html file type? If it is an html file extension, the php is not being parsed properly.
Comment/Reply (w/o sign-up)
mrdee
Oct 25 2008, 08:53 AM
Right, I see. The file is indeed saved as a .htm file. When I save as a .php file, the problem is indeed not there. However, sometimes PHP is embedded in a HTML page, and that usually works. So, what do I do then if I ever have to include a piece of PHP into a HTML page? Do I just put a link to a PHP page? Or is there another way to make the server parse the PHP correctly? I seem to remember I have done HTML pages in the past, and there was some PHP code inside the HTML and it worked. All this is not really good for my poor head, confusion all around.
Comment/Reply (w/o sign-up)
xpress
Oct 25 2008, 09:05 AM
QUOTE(mrdee @ Oct 25 2008, 02:23 PM)  However, sometimes PHP is embedded in a HTML page, and that usually works. So, what do I do then if I ever have to include a piece of PHP into a HTML page? Do I just put a link to a PHP page? Or is there another way to make the server parse the PHP correctly? When you embed php code into the html file you should save the file with .php extension. If the file is saved as html, the browser simply ingnores everything in between <?php ?> tags and process the rest of the page. Because, it doesn't know these tags. Thats it. When the server process the php file, it process the php elemetns and generates the output simply as html. That's why you won't see any php code when you view the source of the page in browser. I think this is your problem. If not, please more clear.....Actually I didn't understand your problem clearly.
Comment/Reply (w/o sign-up)
mrdee
Oct 25 2008, 09:17 AM
OK, thanks for your explanations, gentlemen. I think I have got it now. I assume, if I embed PHP into a HTML file and then save it as a .php page, the server will parse and execute the PHP correctly, but it will also show the HTML code that is in the page correctly. Is that right? Thanks for the help, once again.
Comment/Reply (w/o sign-up)
xpress
Oct 25 2008, 09:27 AM
QUOTE(mrdee @ Oct 25 2008, 02:47 PM)  I assume, if I embed PHP into a HTML file and then save it as a .php page, the server will parse and execute the PHP correctly, but it will also show the HTML code that is in the page correctly. Is that right? Yes. Actually the server only parses the php code only. It has nothing to do with html directly. Even when you echo or print in php, that output is html. For example try echo "Hello <br /> There";you'll see Hello in one line and There in another line. It is because, the web server treats <br /> tag in html as html tag and simply ingnores it. The html will be rendered by the browser itself. Your web browser renders all this html code and show you the page. No involvement of web server in this. That is php is processed by Web Server and HTML is processed by your browser.
Comment/Reply (w/o sign-up)
truefusion
Oct 25 2008, 02:37 PM
Check the mime type configuration on your account, and see if "htm" is set to be considered as a PHP file.
Comment/Reply (w/o sign-up)
shadowx
Oct 25 2008, 04:32 PM
What you need is to tell the server to parse HTML pages as PHP pages. Add this code: CODE AddType application/x-httpd-php .html (remember to change .html to .htm is thats the extension you use.) to a file named .htaccess (no filename, simply the extension .htaccess ) If on windows name the file something.htaccess and then rename it manually to remove the part before the dot as windows is a fussy character... Then just upload the file to your root directory on your server and that should help. (thats also how they create dynamic images like site.com/image.png?name=shadowx but they use .png instead of .html)
Comment/Reply (w/o sign-up)
coolcat50
Oct 25 2008, 05:29 PM
As good practice, I name all of my files with a .php extension. It is just a more effective way of naming files, especially since I am a heavy PHP user. I have never used the .htm extension, only .php and .html for files like that. I would suggest to just name all of your files with HTML and/or PHP with a .php extension for simplicity's sake.
Comment/Reply (w/o sign-up)
dragonfang00
Nov 7 2008, 04:35 PM
if you want to integrate PHP with HTML you should save with .php extension and you should follow the following code: CODE <?php //starts php echo 'This is a php script'; //ends php ?> /* this should be on one file */ <html> <body> This is a HTML </body> </html>
Comment/Reply (w/o sign-up)
Similar Topics
Keywords : weird, formatting, embedding, php, html
- Weird Write Problem
(3)
Html Form!
Using MySQL?! (4) Hey, I need your help again! I need some good working tutorial how I can update my SQL through HTML
form. I did use some tutorials online found with the help of google; but they do not work properly;
I mean there are still small mistakes. I need to have a good tutorial to follow. It should be
based on security and more things. It has to be done in proper way.......
How Do I Get The Result To "stick" And Add Html Tags?
Help please? (14) $changepage = $_REQUEST ; echo " $changepage "; ?> Okay, I need a way for any
information typed in my textarea to "stick" on the page in which it "posts". Since I am creating a
way for my registered users to decorate their "homepages". So any help, tutorials, etc. would be
greatly appreciated. ^^ Thanks.....
File Checker-how To Check File Whith Html Through Html?
(2) edit:sorry for the mistake it is php not html and its with not whith my code checking script= CODE
$file = '$CHECK'; if (file_exists($file)) { echo "The file $filename exists"; } else
{ echo "The file $filename does not exist"; } ?> my question is how to check the file whith
html example:on a page a text box is provided and a button the user writes a file name (or website)
the user clicks on the submit button then it checks and show it (with the code above) i got the
code CODE $filename=$_POST ; if (file_exists($filename)) { echo "The....
Html Code Tester. Online Script
(15) Yes, yes. I have another script that I have written and I am distributing. I am not entirely sure if
this works. I have not tested it yet, but I will later and post back with a demo and fix it up.
Current script: CODE //Save this as something like htmltest.php function CheckForm() {
$html_unsafe=$_POST ; //Gives us our user input $html_safe=str_replace(" //Starts security measures
$html_safe=str_replace("?>"," ",$html_safe); //User input now secure server side //Still security
issues client side echo $html_safe; //echos our statement } //End function //Main script....
Html Site With Login
Is it possible? (2) Hello. I´m building my own site and I need some help... Is it possible to use a login sistem in php
and mysql database in a html site? ....
Script To Translate Into Bbcode From Html Tags
(1) I was wanting to know how to make a form like they use here for the website form. I want to be able
to turn stuff in to bbcode. If you know how or would be willing to write the script for me could
you email me. will@darkzone3.com . I am william to give all credit to who ever makes it. and i can
put a link back to a site if you want. Please be specific with the topic title. "Help" is never a
good topic title. This is explained in our forum rules. Title modified. ....
<?php ?> Marking Up With Php
How to simply add HTML tags with PHP (0) Just a simple function to mark your queries /smile.gif" style="vertical-align:middle" emoid=":)"
border="0" alt="smile.gif" /> CODE $uzorak = 'Hosting credit'; //use post to get
$uzorak variable $tapeti = "Hosting credits are collected by posting at the forums. The hosting
credits are given after your posts are filtered and depending on its size, you get proportional
hosting credits. Once you get the required credits you can post an application for hosting. One of
our admins will then approve your application after which you can register an account at ht....
Help With Moving Html Form Results To Shopping Cart?
(3) Hello All- So I think I'm tackling a pretty big project here and was looking for some help... I
am fairly new to extensive coding (beyond HTML and a little bit of JavaScript) and wanted to know
how I can recall HTML form results on the next page (in a shopping cart) with a price based on the
choices picked in the form. It sounds complicated...look at this example: Check out this page:
http://www.plugcomputers.com/intelprobuild.php See how when the user goes through and picks all
their computer parts a price at the bottom shows the system price based on their sel....
Problems With Data Formatting
(2) I have a MySQL database which stores articles. A sample article would look like this: CODE This
is a body. This is a body.This is a body.This is a body.This is a body.This is a body.This is a
body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This
is a body.This is a body.This is a body.This is a body. This is a body.This is a body.This is a
body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This
is a body.This is a body.This is a body.This is a body.This is a body. That'....
String/text Formatting?
(4) right i was wondering if someone could help me with this: I notice on this site if i make a topic
for example WAppY rOCks WaP, it will come out like Wappy Rocks Wap. I also want to do this to my
forums, can anyone give me the code to format a string of text in this way? THANKS IN ADVANCE ....
[help]: Php To Html (static) Converter
I need help to use PHP to HTML Conversion (3) Hello Guys, I want to use PHP 2 HTML Conversion for my PHP-Nuke CMS And my PHPbb or IPB Forum, but
don't know or does't have any idea about it. If any know about it than please tell me. In
Trap17.com forum PHP to HTML (Static) conversion example is their, you can see it on your Address
bar, Same thing i want to use with my PHP Codes........ Thanks in advance, i am waiting for your
suggestion....
Logging Dowload Files From Your Server Onto A Html File
(1) Well, i had the idea of logging the downloads from my web in a html file few weeks ago, and i solved
it with a lil php page included in my homepage. You could name the links with a name like
"download.php?file=filename.ext" and then, in the download.php put the next code: (well you put
the html and head and body tags if u want, i only write the php here) CODE if (isset($_GET ))
$file=$_GET ; //so it gets the GET data from url (file=filename.ext); $ip=$_SERVER ;
$file=fopen('download_log.html','a'); $date=date('d-m-y H:i:s'); $text="
".$....
Php And Disabling Html Tags
how can i do this? (11) Hello everyone Im TRYING to make a forum and obviously for security i need to disable HTML tags
being used in posts. i know how to use the str_replace() function but to be honest i think id have
to do that for every single tag. I also trued using the html CODE stuff tag but i need to
be able to use the new line tag to make a new line as all the posts are stored as HTML. if this isnt
clear let me give an example: QUOTE NEW POST PAGE > user makes new post and posts it > PHP
PROCCESSOR PAGE MAKES HTML FILE > NEW HTML FILE CONTAINING THE POST > user veiws ....
Parsing Html As Php
and XAMPP as the server version on Windows (7) On my Trap17 account here, I have an .htaccess file with the following declaration which (I think)
forces all html files to be parsed by the PHP Parsing engine and therefore I can insert snippets of
php scripts into html files. CODE AddType application/x-httpd-php .html .htm However, when I
add an .htaccess file to the local directory of the version of XAMPP on my local machine, it fails.
I have tried to add the .htaccess file to the htdocs folder and elsewhere, but it still doesn't
work to parse html through the php parser. Any ideas on how to get these htm....
Adapting Html Code Embed To Work On Phpnuke
Help With This Html Code Pls (7) QUOTE how can get this html code to work on my phpnuke site? what tags would i
have to enable in the $Allowable HTML part of my config.php file?? Edited topic title. Moved to
Programming. ....
Php Is Doing Some Weird Calculations
(3) Well, I am making a script that is doing lots of different calculations. Everything works, until I
see something very strange: 64 - 63.7035 = 0.29649999999999 It's completely obvious that this
is wrong. The answer should be 0.2965... Why does it do such a stupid error, and how can I fix it?....
Php And Asp.net Form
server control html component (6) does this sort of feature can be done in php. http://www.w3schools.com/aspnet/aspnet_forms.asp or
how and what are the differences.. thanks /huh.gif' border='0' style='vertical-align:middle'
alt='huh.gif' /> ....
Weird Error Messages In Opera
(2) On the bottom of my site, I get weird error messages, but only in Opera (Not firefox or IE). The
messages appears below the last include tag on my site, so they appear on the bottom of the page. I
get two different messages: QUOTE ETag: "9e80b2- HTTP/1Date: Fri, 02 Sep 2005 11:48:28 GMT
Server: Apache/2.0.52 (Unix) Connection: Keep-Alive Keep-Alive: timeout=1, max=98 ETag:
"4b94ff-40c5-98ed0bc0" HTTP/1.1 200 OK Date: Fri, 02 Sep 2005 11:48:28 GMT Server: Apache/2.0.52
(Unix) Last-Modified: Fri, 02 Sep 2005 11:48:26 GMT ETag: "4b9516-1be2-8a1f9680" Accept-Ranges: by....
Html Within Php Coding
Is there a way to read HTML Code? (11) Is there a way to have PHP read a text file, which contains HTML Code, not text to display. This
way i have a simple code in every page, linking to this text file, and then if i'm wanting to
change the code, i only need to change the code in the text file. If that all makes sense?
/biggrin.gif' border='0' style='vertical-align:middle' alt='biggrin.gif' /> I get the feeling it
can be done, but the only code i have seen is one that displays the contents of the text files.....
Parsing .html Pages
(9) This isn't really that urgent but I was wondering, I read somewhere that you can configure you
server to pars all html pages for php code, and I was wondering if that was true, and if trap17 has
that feature enabled?....
Best Php/html
(2) I'm wondering what open source converters are out there already. I'm generating legal
documents that require names addresses etc. I want the ability for the end user to modify the base
document whenever they require. I plan to use the TinyMCE WYSIWYG editor to let the users edit each
page. I will populate names and addresses dynamically based on tags in the text. Is there something
good out there that will convert the html to pdf reliably? ....
Help Importing Mysql Database Results
Need help formatting link (3) I am having trouble formatting my table to display the results of a mySQL query the way I want.
Here is the part of my code: CODE $result = mysql_query("SELECT * FROM uploads WHERE
Category='Drama'") or die(mysql_error()); ?> Title Author File // keeps getting
the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // echo "
"; echo $row ; echo " "; echo $row ; echo " "; echo $row ; echo " "; } echo " "; I want to
make 'Title' show as a hyperlink to 'File' but am at a loss as to how to d....
Executing Scripts Without Include() Function
php function to execute a script w/o showing html markup (3) Hi guys. I have another newbish PHP question. /laugh.gif' border='0' style='vertical-align:middle'
alt='laugh.gif' /> Today, I decided to make a new navigation bar for my site. It doesn't look
good because I just started learning Flash today, so I was basically feeling my way around the
application. Anyways, if you use Flash and you try to validate your site at http://w3.validator.org
, you get a lot of errors for some weird reason. So I was thinking about separating the markup for
embed Flash from the rest of the site's source code. The problem with that i....
Html Font Tags In Php
editing fonts using html? (11) I have a php script thats is fully written in php (no html at all). Now for my question, how can i
edit the fonts? Ill make it easier to understand, the following is a data script (found the
script): CODE $mese ="-"; $mese ="January"; $mese ="February"; $mese ="March"; $mese ="April";
$mese ="May"; $mese ="June"; $mese ="July"; $mese ="August"; $mese ="September"; $mese ="Octobre";
$mese ="November"; $mese ="December"; $giorno ="Sunday"; $giorno ="Monday"; $giorno ="Tuesday";
$giorno ="Wednesday"; $giorno ="Thursday"; $giorno ="Friday"; $giorno ="Saturday"; $gis....
Html Frames
how do i wrap html into php (7) hi all what i want to know is does anybody know a way to input html code into php /blink.gif"
style="vertical-align:middle" emoid=":blink:" border="0" alt="blink.gif" /> because i want to bulid
a website using frames but i wish for with to run using php or if theres a way of creating frames
using php that would be better for me. if any of u people got some good advice or links please
reply. Thanks /ph34r.gif" style="vertical-align:middle" emoid=":ph34r:" border="0"
alt="ph34r.gif" />....
Html To Php Questions
(3) Hi, I would like to know if it is safe to change HTML files to PHP files by just changing the
dotHTML extension to dotPHP?? I tried it to a single html file because i used a php code of blog,
and it worked. I'm using Internet Explore version 6 and it's working fine. I would like to
know if the PHp files would work for other browsers after changing dotHTML to dotPHP extension.
Thanks....
ansi 2 html
(1) well im starting to use my old ansi parser to display ansi charactors on websites as though they
were txt.. php is neat about lett me doing that... except i forgot exactly how i did it before.. if
anyone has any idea where to get started let me know please....
Looking for weird, formatting, embedding, php, html
|
Searching Video's for weird, formatting, embedding, php, html
See Also,
|
advertisement
|
|