473,805 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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()+31536000 0);
;}?>
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.ph p"--> 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
10 3162
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
3385
by: aa | last post by:
Is it OK to include an ANSI file into a UTF-8 file?
6
3428
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: <script src="include.js" type="text/javascript"></script> with include.js containing: document.write("<table>")
10
4021
by: $kr1p7_k177y | last post by:
-Without using frames. -- .............................................................................. Chase after truth like hell and you'll free yourself, even though you never touch its coat-tails. -Clarence Darrow
8
207675
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
1923
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 placed in separate smaller files the web server will have to process several other requests for script files, which will impact the performance of the server. Is that concern well placed? If so, is there some other way to break up a large...
1
1631
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 guess I'll use ASPHTTP to do an http call to the file but first I wanted to see if there was a more elegant way to do it...! Is there an efficient way to include the output of a .cgi file in an ASP file?
2
1977
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 convert it to VB? I heard something about using a component..is this true? Options? Thanks all!
5
3482
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 my pages.) Thanks for your help.
2
1555
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 file with the usercontrol so that it will be available where ever the control is used. Does anyone know how to include the file? Thanks
0
9718
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10107
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3846
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.