There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot browser bsod computer connection cpu crash css dell desktop driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor network networking outlook outlook 2003 outlook 2007 outlook express password popups problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
General Website Questions


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
MMJ's Avatar
MMJ MMJ is offline
Distinguished Member with 3,196 posts.
 
Join Date: Oct 2006
10-Nov-2006, 02:07 AM #1
General Website Questions
in /index.html I have this line:

Code:
<div id="sidebar">
<?php include('/home/user/public_html/sidebar.php'); ?>
</div>
in tech/index.php i have the same line.

it only appears in tech/index.html. why?

Last edited by MMJ : 10-Nov-2006 05:49 AM.
deepdiver01's Avatar
Senior Member with 728 posts.
 
Join Date: Dec 2004
Location: Cairns, Australia
Experience: Intermediate
10-Nov-2006, 04:05 AM #2
Looks like a path problem,and I amguessing that the sidebar.php file is sitting in the tech folder.

For the first index.php file, try

<?php include('/home/user/public_html/tech/sidebar.php'); ?>
MMJ's Avatar
MMJ MMJ is offline
Distinguished Member with 3,196 posts.
 
Join Date: Oct 2006
10-Nov-2006, 05:42 AM #3
I renamed index.html to index.php

Solved.
MMJ's Avatar
MMJ MMJ is offline
Distinguished Member with 3,196 posts.
 
Join Date: Oct 2006
10-Nov-2006, 05:48 AM #4
Question 2:

Why does it make a difference if a webpage is named index.html or index.php?
brendandonhu's Avatar
Distinguished Member with 15,988 posts.
 
Join Date: Jul 2002
Location: Ann Arbor, MI
Experience: Advanced
10-Nov-2006, 06:54 AM #5
That's an absolute path so it will work in any directory on that server.
.html files aren't parsed for PHP by default. You normally need to use a .php file to use PHP code.
MMJ's Avatar
MMJ MMJ is offline
Distinguished Member with 3,196 posts.
 
Join Date: Oct 2006
10-Nov-2006, 06:56 AM #6
Thanks! Even if it has php tags?

Question 3: I have this line (/template/sidebar.php') template is a folder under public_html. why is it not finding it?

NOTE: My experience level does not apply to web design
covert215's Avatar
Account Disabled with 2,651 posts.
 
Join Date: Apr 2006
Experience: Web Designer
10-Nov-2006, 08:15 AM #7
You can use HTML in a php file, but you can't use php in an HTML file.
MMJ's Avatar
MMJ MMJ is offline
Distinguished Member with 3,196 posts.
 
Join Date: Oct 2006
10-Nov-2006, 08:54 AM #8
Thanks covert!

if you put / at the beginning of a file path what does it mean?
Eriksrocks's Avatar
Computer Specs
Senior Member with 1,859 posts.
 
Join Date: Aug 2005
Location: Minnesota
Experience: Advanced
10-Nov-2006, 10:01 AM #9
A starting / means from the root directory, really like from your public_html folder or from the domain. If you don't have a / at the beginning it will use the current directory that your file is in as the starting point.

FYI ../ means to go back a directory from the current position, so if you had

domain.com/test/page.html and
domain.com/myfolder/new.html

and you had a link on /test/page.html and you wanted to link to /myfolder/new.html you could either do it like this:

/myfolder/new.html or like this: ../myfolder/new.html

Quote:
You can use HTML in a php file, but you can't use php in an HTML file.
Sure you can use PHP in an HTML file. All you have to add is a couple lines in .htaccess so that PHP will parse HTML files and you're set.
MMJ's Avatar
MMJ MMJ is offline
Distinguished Member with 3,196 posts.
 
Join Date: Oct 2006
10-Nov-2006, 10:22 AM #10
ok this is where the file is:

public_html/template/123.php

This is how I put it in the webpage:

/template/123.php

but it doesn't find it. why?
Eriksrocks's Avatar
Computer Specs
Senior Member with 1,859 posts.
 
Join Date: Aug 2005
Location: Minnesota
Experience: Advanced
10-Nov-2006, 10:26 AM #11
Can you access it at yourdomain.com/template/123.php?

It should work fine. I don't know maybe try using /public_html/template/123.php.
MMJ's Avatar
MMJ MMJ is offline
Distinguished Member with 3,196 posts.
 
Join Date: Oct 2006
10-Nov-2006, 10:27 AM #12
to fix the problem I have put:

/home/mmj/public_html/template/123.php

but I want it to be cleaner than this
Eriksrocks's Avatar
Computer Specs
Senior Member with 1,859 posts.
 
Join Date: Aug 2005
Location: Minnesota
Experience: Advanced
10-Nov-2006, 10:29 AM #13
Then just use a relative path as I described above instead of an absolute one.

e.g. don't have a / at the beginning and use a ../ or multiple ../s if you have to.
MMJ's Avatar
MMJ MMJ is offline
Distinguished Member with 3,196 posts.
 
Join Date: Oct 2006
10-Nov-2006, 12:22 PM #14
Question:

You know how on a lot of website they will have a link that ends with this "/#something" which jumps to another portion of the page. Well how do I work that?

EDIT:SOLVED
namenotfound's Avatar
Computer Specs
Distinguished Member with 2,049 posts.
 
Join Date: Apr 2005
Location: New York
Experience: I know what I know, I am what I am.
10-Nov-2006, 03:22 PM #15
Quote:
Originally Posted by covert215
You can use HTML in a php file, but you can't use php in an HTML file.
You could always add it in .htaccess

AddType application/x-httpd-php .html
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 01:09 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.