What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » PHP Question

Pages: (3): « First « 1 [ 2 ] 3 » Last »
PHP Question
Author: Message:
stoshrocket
Senior Member
****

Avatar
formerly methos

Posts: 748
Reputation: 31
33 / Male / Flag
Joined: Aug 2005
RE: PHP Question
quote:
Originally posted by Eddie
Now THATS what im after, thank you very much :P You've been of great help :D

+1 (Y)
You're very welcome, I like teh PHP =)

This post was edited on 04-02-2009 at 11:38 PM by stoshrocket.
formerly methos
03-31-2009 05:49 PM
Profile PM Web Find Quote Report
davidpolitis
Full Member
***


Posts: 371
Reputation: 16
Joined: Aug 2006
RE: PHP Question
You might wanna also use a .htaccess file to disallow access to all the files in $dir.
04-02-2009 07:43 AM
Profile PM Find Quote Report
Eddie
Veteran Member
*****


Posts: 2078
Reputation: 30
32 / Male / Flag
Joined: Oct 2005
Status: Away
O.P. RE: PHP Question
Another question, how would i go about including different directories, i understand what you said, but then your llama output only allows for one directory.

For example i have the following directories.
/page/info/
/page/users/
/page/resources/

Using your method above how would i do this? If its not possible i will just combine all the pages, but yeah.

Also further questions, if anyone knows PHP/MySQL information...

What i'm making is a Virtual Airline for a friend of mine and myself, i am very bored at the moment incase you wish to know, but anyway...im creating a routes table on my database and what i want to happen is;

On my routes page the url will look like http://www.address.com/index.php?page=routes

And of course on that page there will be a table listing all the routes, that are to be grabbed from my database and sorted by "FlightID". For example i have a flight AAA123 in the table, i want the FlightID to be a link to a page like the following;

http://www.address.com/index.php?page=routes&flightid=AAA123

And i want this to occur to every row for each FlightID.

(On a note to the above, it would be even better, if that link would load up a generic page but with the correct FlightID in the url, which it loading all of the data from the AAA123 row in my database.)

Next up is a submit report page, im having a little trouble with it, ive at the moment got it working on seperate pages for each FlightID, which is quite an effort, but isnt really very convenient if i wished to change them.

What will happen is, on the page;
http://www.address.com/index.php?page=booked_flights&flightid=AAA123

There will be a link to File a Pirep. Is it possible to make that link open a new generic page, which will automatically fill in data from the AAA123 row of my database as part of a form, but also allowing user-input, if you don't understand i will upload an example to my website so you can see what i mean.

Sorry if it doesnt make sense, im trying to explain the best i can what i need, it has been a while since i coded like this so im just having a bit of trouble getting it "on to paper".

This post was edited on 04-02-2009 at 08:36 AM by Eddie.
...there used to be a signature here :)
04-02-2009 08:33 AM
Profile PM Web Find Quote Report
stoshrocket
Senior Member
****

Avatar
formerly methos

Posts: 748
Reputation: 31
33 / Male / Flag
Joined: Aug 2005
RE: PHP Question
quote:
Originally posted by Eddie
Another question, how would i go about including different directories, i understand what you said, but then your llama output only allows for one directory.

For example i have the following directories.
/page/info/
/page/users/
/page/resources/

Using your method above how would i do this? If its not possible i will just combine all the pages, but yeah.

Easy fix, you just add the directory before the page name variable. So for your exmaple detailed in your post...
PHP code:
$page = $_GET['p'];
$llama = "./page/"."$page".".hz";
 
if(file_exists($llama) == TRUE){
include ($llama);
}
else{
include("error.php")
}


then a link to file.hz in ./page/info/ would be...
HTML code:
<a href="?page=info/file">link</a>


Edit: Posted re-written/heavily edited re to segosa's comment about the coding, and to rectify a couple of minor mistakes.

This post was edited on 04-03-2009 at 12:14 PM by stoshrocket.
formerly methos
04-02-2009 12:10 PM
Profile PM Web Find Quote Report
davidpolitis
Full Member
***


Posts: 371
Reputation: 16
Joined: Aug 2006
RE: RE: PHP Question
quote:
Originally posted by Eddie
On my routes page the url will look like http://www.address.com/index.php?page=routes

And of course on that page there will be a table listing all the routes, that are to be grabbed from my database and sorted by "FlightID".
Use a MySQL query something along the lines of this:
code:
SELECT FlightID, FlightName, FlightDate FROM news ORDER BY FlightID ASC

quote:
Originally posted by Eddit
For example i have a flight AAA123 in the table, i want the FlightID to be a link to a page like the following;

http://www.address.com/index.php?page=routes&flightid=AAA123
Again, use a query something along the lines of the query below for the page to select your Flight:
code:
SELECT * FROM FlightTable WHERE FlightID=$FlightID

If you want, add me on Messenger (check my profile) and I'll try help you with your pages and try fix code for you when I can. :P

This post was edited on 04-02-2009 at 01:02 PM by davidpolitis.
04-02-2009 12:52 PM
Profile PM Find Quote Report
segosa
Community's Choice
*****


Posts: 1407
Reputation: 92
Joined: Feb 2003
RE: PHP Question
PHP code:
if(file_exists($llama) == TRUE){
include ($llama);
}
elseif(file_exists($llama) == FALSE){
include("error.php")
}


You seem to know what you're doing, so why do you write code like this? Assuming no caching, not only does it require two (if the first test fails) filesystem queries, but it's just downright pointless to do the check twice. If the first fails, then the result of file_exists is obviously false, and hence the else clause would be more than suitable.

PHP code:
if(file_exists($llama) == TRUE){
include ($llama);
}
else {
include("error.php")
}


quote:
Another way of doing it so you don't end up filling the url with messy slashes (and possibly confuddling your browser)

Why would it confuse the browser? They are generally indifferent to everything placed after the domain name, and will automatically urlencode what is necessary (like spaces).

http://blah.com/?f'dfd//s?'sd/744$///////idi2?444

will still result in "GET /?f'dfd//s?'sd/744$///////idi2?444 HTTP/1.1" being sent to the server (possibly after urlencoding). Using another character just adds another pointless level of abstraction.

This post was edited on 04-02-2009 at 11:10 PM by segosa.
The previous sentence is false. The following sentence is true.
04-02-2009 10:05 PM
Profile PM Find Quote Report
stoshrocket
Senior Member
****

Avatar
formerly methos

Posts: 748
Reputation: 31
33 / Male / Flag
Joined: Aug 2005
RE: PHP Question
quote:
Originally posted by segosa

You seem to know what you're doing, so why do you write code like this? ...

All true, I don't know why I did that, probably down to a combination of tiredness during typing and just inefficient coding... Sorry and thanks for pointing it out though.

Edit: Post in question edited in response

This post was edited on 04-02-2009 at 11:36 PM by stoshrocket.
formerly methos
04-02-2009 11:23 PM
Profile PM Web Find Quote Report
davidpolitis
Full Member
***


Posts: 371
Reputation: 16
Joined: Aug 2006
RE: RE: PHP Question
quote:
Originally posted by segosa
PHP code:
if(file_exists($llama) == TRUE){
include ($llama);
}
else {
include("error.php")
}


quote:
The == TRUE part also may as well as be removed as file_exists returns a boolean value...
PHP code:
if(file_exists($llama)){
include ($llama);
}
else {
include("error.php")
}

:P

This post was edited on 04-03-2009 at 06:53 AM by davidpolitis.
04-03-2009 06:49 AM
Profile PM Find Quote Report
Eddie
Veteran Member
*****


Posts: 2078
Reputation: 30
32 / Male / Flag
Joined: Oct 2005
Status: Away
O.P. RE: PHP Question
code:
<div id="content">
    <?
      $page = GET['p'];
      $llama = "./page/"."$page".".mdu";
      if(file_exists($llama) == TRUE){
          include ($llama);
      }
      else{
          include("error.php")
      }
?>
    </div>

Is returning the following error;

Parse error: parse error in C:\xampp\htdocs\vabase\main.php on line 29

Line 29 is "$page = GET['p'];"
...there used to be a signature here :)
04-03-2009 06:50 AM
Profile PM Web Find Quote Report
NanaFreak
Scripting Contest Winner
*****


Posts: 1476
Reputation: 53
32 / Male / Flag
Joined: Jul 2006
RE: PHP Question
do you have any previous php code? because you could have an error there... also i see that there is no ; on the include("error.php") ;)


edit: you need to change the line that is erroring to $_GET['p']; ;)

also to highlight a line in code you can use

>>> the text you are wanting to highlight <<<

in the code tags

This post was edited on 04-03-2009 at 07:05 AM by NanaFreak.
04-03-2009 06:54 AM
Profile PM Find Quote Report
Pages: (3): « First « 1 [ 2 ] 3 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On