View previous topic :: View next topic |
Author |
Message |
PaulK -
Joined: 26 Apr 2006 Posts: 132 Location: London, UK
|
Posted: Mon May 01, 2006 11:07 am Post subject: Embeding PHP within HTML assistance pls |
|
|
HI Guys
I wonder if you can help me with some basic scripting, I am a novice at this but I'm eager to learn.
I am trying to adapt the stats script from abyssunderground.co.uk to suit my own design. As I don't know very much php I am trying to design my web page using the Namo4 web editor (HTML) I set up a basic bage and tried to include some php which doesnt seem to be working.
Examples can be found on my site:
Working stats from form abyssunderground
http://viahome.co.uk/serverstats/stats.php
My stripped down html test page with embedded php
http://viahome.co.uk/serverstats/viahome.html
Basically, can you tell me what is wrong with the following code as none of the php includes seem to work:
viahome.html
Code: | <?php
<?php include('config.php'); ?>
>?
<html>
<head>
<title>ViaHome.co.uk</title>
</head>
<p><b><font size="4">ViaHome.co.uk</font></b></p>
<p></p>
<p><b><font size="1">Current Servic Status</font></b></p>
<?php
<?php include('services/php.php'); ?>
<?php include('services/asp.php'); ?>
<?php include('services/mysql.php'); ?>
<?php include('services/ftp.php'); ?>
<p><b><font size="1">Little php parsing test</font></b></p>
<?php $var=5;
<p>The variable $var has a value of:
<?php echo($var); ?>
?>
</p>
</body> |
I have been pulling my hair out for about 4 days now, any pointers would be most welcome.
I am using Abyss v2.3 and php v4
Thanks
Paul |
|
Back to top |
|
 |
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Mon May 01, 2006 11:23 am Post subject: |
|
|
Code: | <?php
<?php include('config.php'); ?>
>? |
should be
Code: | <?php include('config.php'); ?> |
_________________ Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk |
|
Back to top |
|
 |
roganty -
Joined: 08 Jun 2004 Posts: 357 Location: Bristol, UK
|
Posted: Mon May 01, 2006 11:25 am Post subject: Re: Embeding PHP within HTML assistance pls |
|
|
PaulK, your problem seems to be "double taging" php code blocks
and including stright html within php code blocks
This is your original:
Code: | <?php
<?php include('config.php'); ?>
>?
<html>
<head>
<title>ViaHome.co.uk</title>
</head>
<p><b><font size="4">ViaHome.co.uk</font></b></p>
<p></p>
<p><b><font size="1">Current Servic Status</font></b></p>
<?php
<?php include('services/php.php'); ?>
<?php include('services/asp.php'); ?>
<?php include('services/mysql.php'); ?>
<?php include('services/ftp.php'); ?>
<p><b><font size="1">Little php parsing test</font></b></p>
<?php $var=5;
<p>The variable $var has a value of:
<?php echo($var); ?>
?>
</p>
</body> |
And this is what it should look like:
Code: | <?php include('config.php'); ?>
<html>
<head>
<title>ViaHome.co.uk</title>
</head>
<p><b><font size="4">ViaHome.co.uk</font></b></p>
<p></p>
<p><b><font size="1">Current Servic Status</font></b></p>
<?php include('services/php.php'); ?>
<?php include('services/asp.php'); ?>
<?php include('services/mysql.php'); ?>
<?php include('services/ftp.php'); ?>
<p><b><font size="1">Little php parsing test</font></b></p>
<?php $var=5;?>
<p>The variable $var has a value of:
<?php echo($var); ?>
</p>
</body>
</html> |
Have you spotted the difference?
The above code can be "cleaned up" further:
Code: | <?php include('config.php'); ?>
<html>
<head>
<title>ViaHome.co.uk</title>
</head>
<p><b><font size="4">ViaHome.co.uk</font></b></p>
<p></p>
<p><b><font size="1">Current Servic Status</font></b></p>
<?php
include('services/php.php');
include('services/asp.php');
include('services/mysql.php');
include('services/ftp.php');
?>
<p><b><font size="1">Little php parsing test</font></b></p>
<?php
$var=5;
echo "<p>The variable $var has a value of: $var</p>";
//echo can work with or without the ()
?>
</body>
</html> |
_________________ Anthony R
Roganty | Links-Links.co.uk |
|
Back to top |
|
 |
PaulK -
Joined: 26 Apr 2006 Posts: 132 Location: London, UK
|
Posted: Mon May 01, 2006 11:38 am Post subject: |
|
|
Thanks for the reply guys, I understand aboout the double tagging now, simple mistake and makes sense.
However the code still don't work in that none of the includes are reported. I have saved Anthony's cleaned up code at
http://viahome.co.uk/serverstats/viahome1.html
As you can see it all works but the includes are missing
Andy, your update is included in the cleaned up code, thanks
I really appreciate your help :)
Paul |
|
Back to top |
|
 |
roganty -
Joined: 08 Jun 2004 Posts: 357 Location: Bristol, UK
|
Posted: Mon May 01, 2006 11:51 am Post subject: |
|
|
PaulK wrote: | Thanks for the reply guys, I understand aboout the double tagging now, simple mistake and makes sense.
However the code still don't work in that none of the includes are reported. I have saved Anthony's cleaned up code at
http://viahome.co.uk/serverstats/viahome1.html
As you can see it all works but the includes are missing
Andy, your update is included in the cleaned up code, thanks
I really appreciate your help :)
Paul |
The page that you have put up isn't showing any include() errors
for example:
Quote: | Warning: main(config.php): failed to open stream: No such file or directory in /abyssws/htdocs/test_code01.php on line 1
Warning: main(): Failed opening 'config.php' for inclusion (include_path='.:/usr/share/pear') in /abyssws/htdocs/test_code01.php on line 1 |
So, unless you have error reporting turned off, it is including the files.
as to why the echo function isn't working is a mystry
mabe TRUSTpunk can help?
btw i spotted an error in my code
i should of escaped the first $ signs in the echo function
Code: | echo "<p>The variable \$var has a value of: $var</p>"; |
_________________ Anthony R
Roganty | Links-Links.co.uk |
|
Back to top |
|
 |
PaulK -
Joined: 26 Apr 2006 Posts: 132 Location: London, UK
|
Posted: Mon May 01, 2006 12:25 pm Post subject: |
|
|
I'm not sure why errors are not reporting, Im using php4 adn copied php.ibi-recommended to php.ini a snippet of the ini file is here:
Code: | error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR
; Print out errors (as a part of the output). For production web sites,
; you're strongly encouraged to turn this feature off, and use error logging
; instead (see below). Keeping display_errors enabled on a production web site
; may reveal security information to end users, such as file paths on your Web
; server, your database schema or other information.
display_errors = On
; Even when display_errors is on, errors that occur during PHP's startup
; sequence are not displayed. It's strongly recommended to keep
; display_startup_errors off, except for when debugging.
display_startup_errors = On
; Log errors into a log file (server-specific log, stderr, or error_log (below))
; As stated above, you're strongly advised to use error logging in place of
; error displaying on production web sites.
log_errors = On
; Set maximum length of log_errors. In error_log information about the source is
; added. The default is 1024 and 0 allows to not apply any maximum length at all.
log_errors_max_len = 1024 |
so I don't understand why I don't see anything the full ini file has been copied to http://viahome.co.uk/php.ini so you can take a look if it helps in any way.
I made the code updates but still no includes :(
Sorry guys, I didn't think this would turn into a chore
Paul |
|
Back to top |
|
 |
PaulK -
Joined: 26 Apr 2006 Posts: 132 Location: London, UK
|
Posted: Mon May 01, 2006 12:27 pm Post subject: |
|
|
I also added a body statement as it is closed off at the end
full code of http://viahome.co.uk/serverstats/viahome1.html with updates:
Code: | <?php include('config.php'); ?>
<html>
<head>
<title>ViaHome.co.uk</title>
</head>
<body>
<p><b><font size="4">ViaHome.co.uk</font></b></p>
<p></p>
<p><b><font size="1">Current Servic Status</font></b></p>
<?php
include('services/php.php');
include('services/asp.php');
include('services/mysql.php');
include('services/ftp.php');
?>
<p><b><font size="1">Little php parsing test</font></b></p>
<?php
$var=5;
echo "<p>The variable \$var has a value of: $var</p>";
//echo can work with or without the ()
?>
</body> |
update: copied php.ini to c:\windows restarted server - no change
Update: nothing reported in the cgi.log or fastcgi.log |
|
Back to top |
|
 |
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Mon May 01, 2006 1:08 pm Post subject: |
|
|
Include() throws a warning on failure, and your error reporting level doesn't include warnings.
E_ALL & ~E_NOTICE will show everything but notices, try that. _________________
 |
|
Back to top |
 |
 |
PaulK -
Joined: 26 Apr 2006 Posts: 132 Location: London, UK
|
Posted: Mon May 01, 2006 1:26 pm Post subject: |
|
|
Thanks for that, edited c:\windows\php.ini
(and copied to http://viahome.co.uk/php.ini)
still no change I'm afraid |
|
Back to top |
|
 |
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Mon May 01, 2006 2:08 pm Post subject: |
|
|
As to the initial problem (Which I've only just bothered to read.), php isn't parsing it, add .html to the list of extensions it uses, or change it to .php or something. _________________
 |
|
Back to top |
 |
 |
PaulK -
Joined: 26 Apr 2006 Posts: 132 Location: London, UK
|
Posted: Mon May 01, 2006 2:56 pm Post subject: |
|
|
Ha so simple, cant beleive I missed it!
THANK YOU it nows works perfectly :)
Thanks to everyone who help me out
Paul |
|
Back to top |
|
 |
|