Jump to content

Recommended Posts

Posted

Okay I'll admit it, I'm really just learning PHP and this is probably REALLY stupid but I've exhausted all my resources so I thought I'd try here. I want to include a stupid simple PHP/mySQL counter routine in each of my pages.

 

If I call the counter script directly i.e. www.villagebistro.info/counter/counter.php it works.

 

I try to include it in the footer of my pages using:

 

<body ... blah blah blah

...

<?php

include ("..\counter\counter.php");

?>

</body>

 

and that is exactly what appears when I use the "View Source" command from my browser window. I've tried moving it *everywhere* in the html file to no avail. It doesn't seem to be doing the include :)

 

I'm feeling really stupid right now so I'm going to knock off for the day and have a glass of scotch and contemplate the meaning of life for a little while.

 

I'd really appreciate one of you "PHP gurus" giving me a hand here ... Thanks in advance,

Paul

Posted

I'm pretty new at PHP myself, so I hope this doesn't sound too ridiculous:

 

When I had that problem, I suddenly realized that the file I added the PHP code was still saved as .HTML. When I resaved the file using the .PHP extension, it worked.

 

I only mention this since you said:

 

is exactly what appears when I use the "View Source" command from my browser window. I've tried moving it *everywhere* in the html file to no avail.

 

It was the "...in the html file" part that made me wonder if your page had the right extension.

 

I hope this helps,

 

aikiDave

Posted

:) To quote the very wise and honorable Homer Simpson .... DOH! Ridiculous? Ridiculous? No ridiculous, is my total lack of knowledge LOL ... Haven't tried it yet, cuz' the scotch is just too damn good but it sounds perfectly logical to me!

 

Thanks a bunch for opening yet another window on this poor old scotch soaked brain! ;)

 

Later,

Pauol

Posted

Well, if that doesn't work, here's a snippet of what I use to include a file:

 

<?PHP

include($DOCUMENT_ROOT . '/name of file');

?>

 

So, to include the counter, you would probably put:

 

<?PHP

include($DOCUMENT_ROOT .'/counter/counter.php');

?>

 

Might want to check your code and see if it looks like this at all.

 

Again, hope this helps,

 

aikiDave

Posted

Dave thanks a LOT! A simple change of the file name was all it took LOL Yeah, I'm feeling kinda' dumb about now but maybe I can redeem myself by getting some scripts working today :angry:

 

Thanks again,

Paul

Posted

Glad I was able to help!

 

And no need to feel dumb--if I had a nickel for every time I wondered why a script wouldn't run, only to discover that I hadn't put a semi-colon somewhere.... Sheesh. :angry:

 

Hope your scripts go well,

 

aikiDave

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...