473,320 Members | 1,887 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to Include PHP script in shtml file ???

I have a php site I have an include line called "include 'Cookie.php';"

In this Cookie.php file I have these codes.

<?php
$conn = mysql_connect("$db", "$user", "$pass");
mysql_select_db("$db");

//--------------------------------------------------------------------------
-------------
//COOKIE
//--------------------------------------------------------------------------
-------------
$cookiename = 'TourCounter';
if( isset( $_COOKIE[$cookiename] ) ){$user_id = $_COOKIE[$cookiename];}
else {
mysql_query ("INSERT INTO CountUser (Dato) VALUES (now())");
$user_id = mysql_insert_id();
setcookie( $cookiename, $user_id, time()+315360000);
;}?>
This will set a cookie on the computer when people enters the site for the
first time, and update my database.
Now I can see how many new computers that see my site each day, and it works
fine.
BUT, now I have another site where all the pages are .shtml sites, and I
have not been using any php scripting at all, though it is uploadet on a
server where I can use php.

But now I can't include the file, cause if I write <!--#include
file="Cookie.php"--> it includes some php codes, but since the site is
called .shtml it offcause can't execute the php script.

But isn't there a way to do this anyway.
Maybe by some javascript that executes the Cookie.php fil or something. ??
The site has a lot a pages, and I would rather not rename them all to .php
and the shtml include to php include on all the pages.

I have a menu that is included on all the pages, so if it could be executed
in the menu file, I will count all hits, nomatter what site people enters
first.
Hope someone have a good idea.

best
Michael
Oct 27 '05 #1
10 3109
Lee
EnjoyNews said:

I have a php site I have an include line called "include 'Cookie.php';"

In this Cookie.php file I have these codes.


You seem to be asking a PHP question in a Javascript newsgroup.
Asking in a more appropriate place will produce better answers.

Oct 27 '05 #2

"Lee" <RE**************@cox.net> skrev i en meddelelse
news:dj*********@drn.newsguy.com...
EnjoyNews said:

I have a php site I have an include line called "include 'Cookie.php';"

In this Cookie.php file I have these codes.


You seem to be asking a PHP question in a Javascript newsgroup.
Asking in a more appropriate place will produce better answers.


No I not asking a php question.
The php script is working fine on my other site, which is coded in php.

But now I need the php script to be executed from a .shtml site.
So now I can't include the Cookie.php script, since it only works if the
site is called .php

So therefore I'm asking here if I somehow can execute a .php fil with
jacvascript.
Oct 27 '05 #3
On 27/10/2005 15:47, EnjoyNews wrote:

[snip]
But now I need the php script to be executed from a .shtml site.
That still isn't a question for this group. That's a server
configuration issue.

What's a .shtml site, anyway?
So now I can't include the Cookie.php script, since it only works if the
site is called .php


The extension used is really rather irrelevant. A server could send
files that have the extension .cheese to PHP.

If you want the server to pass a file through PHP, then either name that
file in a way that will make the server do that (usually using an .php
extension), or change the server configuration.

[snip]

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Oct 27 '05 #4

EnjoyNews wrote:
I have a php site I have an include line called "include 'Cookie.php';"

In this Cookie.php file I have these codes.

<?php
$conn = mysql_connect("$db", "$user", "$pass");
mysql_select_db("$db");

//--------------------------------------------------------------------------
-------------
//COOKIE
//--------------------------------------------------------------------------
-------------
$cookiename = 'TourCounter';
if( isset( $_COOKIE[$cookiename] ) ){$user_id = $_COOKIE[$cookiename];}
else {
mysql_query ("INSERT INTO CountUser (Dato) VALUES (now())");
$user_id = mysql_insert_id();
setcookie( $cookiename, $user_id, time()+315360000);
;}?>
This will set a cookie on the computer when people enters the site for the
first time, and update my database.
Now I can see how many new computers that see my site each day, and it works
fine.
BUT, now I have another site where all the pages are .shtml sites, and I
have not been using any php scripting at all, though it is uploadet on a
server where I can use php.

But now I can't include the file, cause if I write <!--#include
file="Cookie.php"--> it includes some php codes, but since the site is
called .shtml it offcause can't execute the php script.

But isn't there a way to do this anyway.
Maybe by some javascript that executes the Cookie.php fil or something. ??
The site has a lot a pages, and I would rather not rename them all to .php
and the shtml include to php include on all the pages.

I have a menu that is included on all the pages, so if it could be executed
in the menu file, I will count all hits, nomatter what site people enters
first.
Hope someone have a good idea.

best
Michael


One option to explore may be to use some kind of remote scripting
solution, such as HTTPRequest. There is a lot of information to be
found on the HTTPRequest object.

I.e. when your menu file is loaded and run, you make an HTTPRequest to
"Cookie.php".

E.g. something like:-

var oHTTP=new ActiveXObject("Microsoft.XMLHttp");
oHTTP.open("GET","Cookie.php", false);
oHTTP.send(null);

This is very rough. Have a look at the SARISSA library for
cross-browser versions. It will only work on later browsers, so even if
it works, it may not a complete solution for you.

Julian

Oct 27 '05 #5
EnjoyNews said the following on 10/27/2005 10:47 AM:
"Lee" <RE**************@cox.net> skrev i en meddelelse
news:dj*********@drn.newsguy.com...
EnjoyNews said:
I have a php site I have an include line called "include 'Cookie.php';"

In this Cookie.php file I have these codes.


You seem to be asking a PHP question in a Javascript newsgroup.
Asking in a more appropriate place will produce better answers.

No I not asking a php question.
The php script is working fine on my other site, which is coded in php.

But now I need the php script to be executed from a .shtml site.
So now I can't include the Cookie.php script, since it only works if the
site is called .php

So therefore I'm asking here if I somehow can execute a .php fil with
jacvascript.


How about with plain HTML?

<img src="phpFileToExecute.php" width="0" height="0" style="visibility:
hidden">

Or, you could configure your server to parse .shtml files through PHP.

Either way, it has nothing to do with javascript.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Oct 27 '05 #6

"Randy Webb" <Hi************@aol.com> skrev i en meddelelse
news:U7********************@comcast.com...
EnjoyNews said the following on 10/27/2005 10:47 AM:
"Lee" <RE**************@cox.net> skrev i en meddelelse
news:dj*********@drn.newsguy.com...
EnjoyNews said:

I have a php site I have an include line called "include 'Cookie.php';"

In this Cookie.php file I have these codes.

You seem to be asking a PHP question in a Javascript newsgroup.
Asking in a more appropriate place will produce better answers.


How about with plain HTML?


Yes it's simple html. I just told that the site was called shtml, cause
maybe that has something to do with how the javascript should look like.
But yes it is a standard html site.


<img src="phpFileToExecute.php" width="0" height="0" style="visibility:
hidden">
Is this really possible.... ???
I thought the <img src command could only be used to view images. ???

But if this is possible, it was exactly what I was looking for. A way to
open a file (in this case a .php file) without opening another browser
window or something like that...


Or, you could configure your server to parse .shtml files through PHP.
Is this something I do myself, or do I have to ask my webhost about this ??


Either way, it has nothing to do with javascript.


I know this has nothing to do with javascripting, but I didn't know how to
do it in html, so I thought maybe it could be done with javascripting, and
that's why I asked here..
Oct 27 '05 #7

"Michael Winter" <m.******@blueyonder.co.uk> skrev i en meddelelse
news:n_*******************@text.news.blueyonder.co .uk...
On 27/10/2005 15:47, EnjoyNews wrote:

[snip]
But now I need the php script to be executed from a .shtml site.
That still isn't a question for this group. That's a server
configuration issue.


I thought maybe some javascript in my .html file could execute another file,
in this case a .php file.
That's why I asked here.


What's a .shtml site, anyway?
it's a .html file that uses serverside commands like "include file"
It's not important in this case if it's a html or shtml file, that info was
just to inform which file the javascripting should be placed in, if it was
possible.

So now I can't include the Cookie.php script, since it only works if the
site is called .php


The extension used is really rather irrelevant. A server could send
files that have the extension .cheese to PHP.

If you want the server to pass a file through PHP, then either name that
file in a way that will make the server do that (usually using an .php
extension), or change the server configuration.


It's rather complicated to rename the files from .shtml to .php, since all
the serverside commands used in the files, does not work in an .php file.
That's why I'm not changing the extension.

But how do I get the server to pass .shtml file through PHP. ??
Oct 27 '05 #8
EnjoyNews said the following on 10/27/2005 6:32 PM:
"Randy Webb" <Hi************@aol.com> skrev i en meddelelse
news:U7********************@comcast.com...
EnjoyNews said the following on 10/27/2005 10:47 AM:

"Lee" <RE**************@cox.net> skrev i en meddelelse
news:dj*********@drn.newsguy.com...
EnjoyNews said:
>I have a php site I have an include line called "include 'Cookie.php';"
>
>In this Cookie.php file I have these codes.

You seem to be asking a PHP question in a Javascript newsgroup.
Asking in a more appropriate place will produce better answers.
How about with plain HTML?

Yes it's simple html. I just told that the site was called shtml, cause
maybe that has something to do with how the javascript should look like.
But yes it is a standard html site.
<img src="phpFileToExecute.php" width="0" height="0" style="visibility:
hidden">

Is this really possible.... ???


Yes, it is really possible. It is the basis of most page hit counters.
I thought the <img src command could only be used to view images. ???
Test it and see :)
But if this is possible, it was exactly what I was looking for. A way to
open a file (in this case a .php file) without opening another browser
window or something like that...
Yes, very possible.

Or, you could configure your server to parse .shtml files through PHP.

Is this something I do myself, or do I have to ask my webhost about this ??


Your webhost would have to do it.

Either way, it has nothing to do with javascript.

I know this has nothing to do with javascripting, but I didn't know how to
do it in html, so I thought maybe it could be done with javascripting, and
that's why I asked here..


It can be done with plain HTML.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Oct 27 '05 #9

"Randy Webb" <Hi************@aol.com> skrev i en meddelelse
news:M8********************@comcast.com...
EnjoyNews said the following on 10/27/2005 6:32 PM:
"Randy Webb" <Hi************@aol.com> skrev i en meddelelse
news:U7********************@comcast.com...
EnjoyNews said the following on 10/27/2005 10:47 AM:
"Lee" <RE**************@cox.net> skrev i en meddelelse
news:dj*********@drn.newsguy.com...
>EnjoyNews said:
>
>
>>I have a php site I have an include line called "include 'Cookie.php';">>
>>In this Cookie.php file I have these codes.
>
>You seem to be asking a PHP question in a Javascript newsgroup.
>Asking in a more appropriate place will produce better answers.
>
How about with plain HTML?

Yes it's simple html. I just told that the site was called shtml, cause
maybe that has something to do with how the javascript should look like.
But yes it is a standard html site.
<img src="phpFileToExecute.php" width="0" height="0" style="visibility:
hidden">

Is this really possible.... ???


Yes, it is really possible. It is the basis of most page hit counters.
I thought the <img src command could only be used to view images. ???


Test it and see :)

I have done what you said, and it works perfect.
So now I can upload my folder called Counter, where the Cookie.php file is
in, and a php site to view the result from my MySQL database.
Then all I have to do is put the line
<img src="Counter/Cookie.php" width="0" height="0">
on a site that is view all the time, like the menu.
And then I can see how many new computer that have entered the site. The
cookie is on each computer for 10 years, so if people doens't reinstall, it
will only count one hits from each computer one time in 10 years.

Thanks a lot for you help :o))

Michael
Oct 28 '05 #10
On 27/10/2005 23:38, EnjoyNews wrote:

[snip]
I thought maybe some javascript in my .html file could execute
another file, in this case a .php file. [...]
It could, but it's not a good solution. One of the advantages of using
the server is that you can reliably perform actions using it. Using a
client-side script negates this reliability and, let's face it, the
reason why you're looking for a quick way out is because you're not
inclined to make the necessary effort to solve the problem properly.

[Me:]
What's a .shtml site, anyway?


it's a .html file that uses serverside commands like "include file"


I'm well aware of SSI. You missed my point, but it's not important.

[snip]
It's rather complicated to rename the files from .shtml to .php,
since all the serverside commands used in the files, does not work in
an .php file.
With your server configuration, yes. However, it strikes me as rather
odd that you didn't forsee this issue.

[snip]
But how do I get the server to pass .shtml file through PHP. ??


I'm curious to know why it doesn't anyway. An SSI include element should
pass a PHP script through the preprocessor. The URL for the virtual
attribute value (typically preferred over file) can even include a query
string that can be accessed as usual.

If the server is configured with IncludesNOEXEC, rather than Includes,
then an error will result because permission to execute the script was
not granted, but you made no mention of that.

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Oct 28 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: aa | last post by:
Is it OK to include an ANSI file into a UTF-8 file?
6
by: Spartanicus | last post by:
For a non essential enhancement of one of my pages I'd like to include a remote html file via javascript (server side is not available to me). The "include" method that I'm familiar with: ...
10
by: $kr1p7_k177y | last post by:
-Without using frames. -- .............................................................................. Chase after truth like hell and you'll free yourself, even though you never touch...
8
by: Henri | last post by:
Hi, Is there a way to include a .js file inside a .js file in JavaScript 1.5? Thanx Henri
1
by: Christopher Benson-Manica | last post by:
We have a fairly large (1500 line) .js file that contains script that most of our pages use. My personal opinion is that this is not easy to maintain, but others are concerned that with the script...
1
by: Bill | last post by:
How can I include a .cgi file in an .ASP file? I've tried #include, Server.Transfer, and Server.Execute (yes, I know the last two are only for ASP, but I tried it anyway). If I have to, I...
2
by: Jer425 | last post by:
Hello, I'm coding in VB and trying to include a jscript file. This will not work because you can only use one language in asp.net. Is there a way that I can use the jscript without having to...
5
by: green_tea | last post by:
Hi there, I'd like to know how to include a js file globally in asp.net so all my pages can access js functions in this file. (Only include it once and not include this file one by one to all...
2
by: Academia | last post by:
I want to include a button that opens a .chm help file on a usercontrol. I haven't yet looked at how the button is to open the help but before I go there I need to know how to include the .chm...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.