PHP help please.

Soldato
OP
Joined
24 May 2006
Posts
3,824
Location
Surrey - UK
I could have sworn i wrote a detailed reply earlier outlining some ideas for changing my initial layout to something else.

Has the forum been down today?

I was simply saying that i was having a total rethink of how everything is laid out, and putting the header and footer into functions, then calling them in various index files, those in sub-directories etc...

Also thinking about using arrays for the content instead of case/switch and if/else.

Thanks for all the help marc, i think i'll take some of your earlier comments and later ons onboard and change how i'm laying out the structure of the files.

Would you mind just explaining a few pieces of code for me....

$current
= $_SERVER['SCRIPT_NAME'];

What does SCRIPT_NAME translate to.
PHP website says...

'SCRIPT_NAME' Contains the current script's path. This is useful for pages which need to point to themselves. The __FILE__ constant contains the full path and filename of the current (i.e. included) file. Why is that line required?

Secondly this area.

if(strlen($_SERVER['QUERY_STRING']) > 0) $current .= '?' . $_SERVER['QUERY_STRING'];

'QUERY_STRING' The query string, if any, via which the page was accessed.

So what exactly are you saying in this string, if string length is more than 0? Then current is equal to the string + a question mark?

if(stristr($current, $link))

What does this line do exactly.
http://uk.php.net/manual/en/function.stristr.php

Not sure i fully understand what it's doing still though.

Just want to understand what this is doing, sorry a bit of an impatient learner, lol.... just need a break down of the code, the PHP website itself is very poor (or at least i feel) at explaining things without giving overkill or poor examples, or examples that won't apply to my uses.... :(
 
Last edited:
Soldato
OP
Joined
24 May 2006
Posts
3,824
Location
Surrey - UK
Yeah i see what you're saying and i don't mind using new code i don't yet understand if you can break it down and explain what a given command or piece of code does.

MySQL is available to use but that would mean additional coding and learning, though i understand the basics of retrieving and inputting data in MySQL there's always that issue of ensuring you are doing everything in a way where people can't start using SQL injections on your site, not an extra i want to wrestle with when i know little about the language.

The server where i'll be plonking the pages onto has just been taken down due to SQL injections (was running an older modified version of DragonflyCMS). The forums area had 1 thread containing over 8000 posts to porn images and videos embedded from guest accounts, although guest accounts and HTML in forum posts were disabled...

It's just an extra thing to have to worry about if i start sending and retrieving data from a database.

The other admin has written his own mini CMS (for personal use - very basic functions) with his also limited knowledge so i'll proberly work a mixture of my own work and his.

Just need him to reply to my messages and then we'll compare notes.... :) He's working over the weekend though, so i can't expect him to reply.

The function i was referring for the header and footer would mean you use....

header ();

your page / content here

footer ();

A little quicker (marginal i know) to deal with then using an include for every page.

However currently i use require_once for the header and footer instead of include so pages can't be loaded without the header and footer, but i'm sure you know how that works anyway... ;)
 
Soldato
OP
Joined
24 May 2006
Posts
3,824
Location
Surrey - UK
index.php?this was only applicable to the root page for the given section, though it doesn't have to be that way now i've had some thinking on it.

If i'm only retrieving data from a database how am i putting in there in the first place?

If you're suggesting writing the database tables then i might aswell just be writing a PHP scripted page in less time, if i'm not writing the MySQL tables then i would be inputting data.

Unless i'm misunderstanding again... :(

header() was only an example, it could be myhead() myfoot() for all it matters, was an idea.

In total honesty i don't know what functions, strings or arrays are best used for what. There's lots to read about them, but very little defining what their best uses are, but i think that's down to the given person writing the PHP.

So whether i store, for example, my content in a case/switch or array, or use a database, there's nothing clear and defining i've seen to suggest what should be used where, and why, since there's seems to be many different ways to archive the same thing in PHP.
 
Soldato
OP
Joined
24 May 2006
Posts
3,824
Location
Surrey - UK
Yeah it's just a personal project to make a site to store any guides, tutorials or projects i'd like to share.

Handy for referring friends to......

Even for simple things like Reghacks in Vista for extra context shortcuts etc...

A place to host anything i make, so others can find it and use it..... whatever 'it' may be...

It also saves me from having to keep 100's of bookmarks for things i can't remember off the top of my head ifi can just plonk them on my own page(s).

Code hasn't been the end of my problems either, i have been having issues getting connected via FTP again, connected to my friends server, then could never get connected again. 4 FTP clients later (all with same settings) and i finally get connected. Server users a custom port to just to be a pain also. WS_FTP was the only client that will now work for me connecting to a server on port 7022 ssh.
 
Last edited:
Back
Top Bottom