Jump to content

[SOLVED] <?php ?> in html doen not work


leprkhn

Recommended Posts

i installed debian etch on my computer and set up apache2 php5 and mysql on it. everything seems to be working fine except that any php that i place into html file doesn't show up. i put the php inbetween <?php ?> tags. i even tried <script language="php"> </script> tags, and it still doesn't work. im pretty new to php and linux but im a fast learner.

if anyone could help me out a bit i'd really appreciate it.

is there some .conf file i have to edit?

is it a php problem or an apache problem?

 

thanks

leprkhn

Link to comment
Share on other sites

I'm not familiar with debian etch. I use XAMPP. But, before those tags can work you typically have to place the files in a specific directory on your computer. For XAMPP it's Program Files/XAMPP/htdocs, for example. This may not be the case with your debian etch, though.

Link to comment
Share on other sites

you use php as .php and not .html ok

 

correct

test.php

<?php

 

echo hello;

 

?>

 

not correct

test.html

<?php

 

echo hello;

?>

 

yes. but for some reason using .html read the php file but its better to use .php even in the html file

Link to comment
Share on other sites

ok...

my document root for apache is /var/www/ and thats where 'localhost' in my browser will go to.

inside /var/www/ i have index.html and test.php

test.php contains:

 

<?

echo ("hello");

$_one=1;

$_two=2;

$_three=($_one+$_two);

print($_three);

?>

 

and when the browser is pointed at localhost/test.php it returns hello3. like it should.

 

however.

 

index.html contains:

<html>

<head><title>blah</title></head>

<body>

<p>blah blah blah </p>

<?php

echo ("hello?");

print ("hello?");

?>

</body>

</html>

 

and when the browser is pointed at localhost/index.html it returns:

 

blah blah blah

 

 

 

... and thats it. none of the php gets shown. i dont even know if it's being parsed or just skipped.

 

 

thoughts?

<?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.