Search
Left Quote    If at first you don't succeed, redefine success.
- Anon.    
Right Quote
 
[login] | [Register]
Forum Index » General Discussion » Viewing Topic and Replies
Post Reply


        Viewing Topic: basic syntax, some relative and absolute paths, and a questi
  This user is offline  viospace
  Subject: "basic syntax, some relative and abs..." Posted: @ 2:25 am on Jul 21 2008   

Member #: 717
Rank: User - (7)
Since: 07/13/08
Posts: 4
From: Fairless Hills, PA


:) I typically try to post something that might be useful to someone when I post a question.

Syntax can be a sticking point with php coding. I've commonly, commonly left out a ' or " here or there, forgotten to end a line with a semi-colon. Both of the following with work. The php user manual shows straigt single quotatioin marks, but the latter also works.


Code:
include 'body.php';
Include("f ooter.php" );




Also, I've just been performing some absolute path adjustments because of the layers of directories. For instance, the first is an example of a complete path to a login script, and the latter also will work.


Code:

include 'http://www.vio space.net/test/ phptestfiles/lo gin.php';

include '/test/phptestf iles/login.php' ;




If the login.php is in the same directory, then a simple
Code:
include 'login.php';
will suffice.

Right now I am questioning:

What is an appropriate directory structure to work with for keeping files that have mysql login information stored in?

Is the first directory off of the www.sitename .net/ a safe place or no?

dogstar


dogstar "I want a sandwich!"
    Viewed: 6,924 Times | Reply to This | To top
  This user is offline  David1159
  Subject: "re: basic syntax, some relative and..." Posted: @ 6:39 am on Jul 21 2008    

Member #: 526
Rank: User - (81)
Since: 12/27/07
Posts: 81
From: usa

php is a behind source code, it is not viewable.

I'd recommend you stick to this code style -

include(" footer.php&quo t;

Its proper and will work in all web browsers, remember make sure it is capable not only in Opera or Firefox but IE as well, since IE is what most users operate with.

Now as for how do direct the include to the required file.

Don't use the whole http://... in the include.

-----
If login.php is in Folder 1, and you want to include your database.php which is IN Folder 1, it will look like this.

include(" database.php&q uot;
-----
If login.php is in Folder 1, and you want to include your database.php which is in Folder 2,3,4,etc. It will look like this.

include(" folder2/databas e.php";
-----
Now if you need to go backwards, lets say include something a few folders behind in the order. Like lets include the Login.php in Folder 1 on the database.php in Folder 2. Use this method.

include(" ../folder2/data base.php"< img src=http://www. allsyntax.com/f orums/images/sm ilies/wink.gif border=0>; Will move you 1 folders backwards.
include(" ../../folder2/d atabase.php&qu ot; Will move you 2 folders backwards.
(it might need to be include(" /../folder2/dat abase.php" ; with the / in the front)

I make a folder called "includes ". In there I place important include files that I use in and out of my coding.




Coding is simply CST... Combining $hit Together. We make different $hit to run in unison correctly.

    Viewed: 6,915 Times | Reply to This | To top
  This user is offline  misterhaan
  Subject: "re: basic syntax, some relative and..." Posted: @ 3:12 pm on Jul 22 2008    

Member #: 5
Rank: User - (213)
Since: 02/11/05
Posts: 148
From: chair

include is not a function, so the parenthesis don




please note that the above post is likely made up in its entirety.

    Viewed: 6,898 Times | Reply to This | To top
  This user is offline  viospace
  Subject: "re: basic syntax, some relative and..." Posted: @ 9:53 pm on Jul 22 2008    

Member #: 717
Rank: User - (7)
Since: 07/13/08
Posts: 4
From: Fairless Hills, PA

david and misterhaan, this is all makes sense, thank you.

I use Yahoo! web hosting. I don't have a home server station with a document root, I believe this is what you are referring to when you say OS path. I'm not sure but will check if I have that option with the web hosting. I'll try to search on the Yahoo!Help to see where the root is if it exists.




dogstar "I want a sandwich!" ;

    Viewed: 6,885 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2017; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank