Should I be using php?
Freeola Internet Get Dotted Domains Gaming & Extras
Freeola Gaming & Design
Add a Chat Forum to Your Site Quickly and Easily
 
Browse Chat Forums:
 Chat Forums Home Latest Message Chat Rules Chat Safety & Tips Top Posters How to Win GAD Prizes View the Winners List Update Your Profile See Who's Online
  Free Web Site  Free Domain Hosting  Emergency Internet  Broadband Offers
 

Premium Customer Support

Win Amazon Vouchers!

Visit our Support Pages E-mail a Support Request Contact Us

NOD32 Antivirus available from Freeola

nothing
You Are Here Chat Home (42) Internet  Web Design  "Should I be using ph..."
Just lurking around? Why not join in? You could win free games just by chatting. Choose your Nickname in MyFreeola or Sign Up Here.
 
 
Should I be using php?
Regular
on 04/09/2008 at 5:31:14PM
Total Posts: 10891
Original Post:
I mastered HTML and CSS (kinda), but I never really got into php despite owning a few books.

When I create a site I can change pretty much anything with CSS, but if I want to change big chunks of the site layout I have to alter every single page which is not good. So my question is, should I have studied php all those years ago? Is there anything out there that can do all this form me for free so I dont have to change 100s of webpages individually? Or maybe there's a new programming language in development thats better than ASP and PHP, in which case should I start learning now?

Its okay, this wont affect my current site, but I need to know for future projects. Freeola is done in php right? it cant be that difficult. Could I be able to master it within a week?

Thanks for your help guys, I appreciate it.
View More Threads Post a Reply  
   Delicious   Digg   Reddit      StumbleUpon
Page 1 of 2 1 2 » Last »
Displaying 1 - 40 of 40 Replies:
JimTheDog
"Woof Woof"
Regular
on 30/09/2008 at 8:46:10PM
Total Posts: 19
No probs Machie - let me know how you get on.

Also - if you want to show a random image instead of a whole page then replace the "page1.php, page2.php" etc in the array with "image1.jpg, image2.gif" etc and also add the last lines as


//finally, include the page
    //include_once("$page");
   
    //or show the graphic
?>
<img src="<?php echo $page;?>" />



JTD
Machie
Regular
on 29/09/2008 at 3:05:24PM
Total Posts: 10891
Garin wrote:
> The only difference is how PHP behaves when the file doesnt
> exist.  Include just throws a warning and carries on executing
> the script.  Require throws a fatal error and wont execute the
> rest of the script.
> So up to you really.

In that case something is better than nothing, so I'll stick with includes. Thanks Garin. :)

> I have the header and nav in seperate includes/requires, but as
> they're right next to each other should I just put them into
> one
> file?
>
> Yes?

I'm Ron Burgundy?
Garin
"Devil in disguise"
Regular
on 29/09/2008 at 2:48:42PM
Total Posts: 1743
Machie wrote:
> I have a few questions, should I be using include()
> or require()?

The only difference is how PHP behaves when the file doesnt exist.  Include just throws a warning and carries on executing the script.  Require throws a fatal error and wont execute the rest of the script. 
So up to you really.

> I have the header and nav in seperate includes/requires, but as
> they're right next to each other should I just put them into one
> file?

Yes?
Machie
Regular
on 29/09/2008 at 2:25:05PM
Total Posts: 10891
Oops sorry Jim, I didn't notice you'd done this for me. Thank you so much. :D I'll have to try it out in a bit.

I have a few questions, should I be using include() or require()?

I have the header and nav in seperate includes/requires, but as they're right next to each other should I just put them into one file?
JimTheDog
"Woof Woof"
Regular
on 21/09/2008 at 6:04:47PM
Edited: 21/9/08 18:38
Total Posts: 19
Machie,

In response to your random page include - try this - you will need to create yourpagex.php and include any paths if you create the files in a seperate directory from the page you call this from.

I hope it helps.



<?php
    //start a session
    session_start();

    //create an array. Add your pages here.
    $pageArray = array("page1.php", "page2.php", "page3.php");
           
    //count the elements for later use
    $count=count(pageArray);
   
       
    //check to see if the session var is set (it won't be on the first page load)
    if (isset($_SESSION['page'])) {$lastPage = $_SESSION['page'];} else {$lastPage = -1;}
                       
    //check to see if the same page has been choosen since the last load but not if there is only one page in tha array.
    if ($count >=1){
           
    //chooses a random entry from the array making sure it is not the same as the last page loaded
        do{
        $random = array_rand($pageArray);
        }
        while ($lastPage == $random);
    }
   
    else
   
    {//set the $random var to 0 if there is only one element - NOTE: there is no check for zero length array.
    $random = 0;};
           
    //set the session var for last page
    $_SESSION['page']  = $random;
           
    //get the page to include
    $page= $pageArray[$random];
                   
    //finally, include the page
    include_once("$page");
?>
JimTheDog
"Woof Woof"
Regular
on 20/09/2008 at 10:47:46AM
Total Posts: 19
Machie, Garin is right <BR> should be adequate but if you need a little bit more control then stick a single column, two row table in the <DIV> and set the borders to 0 - put your image in the top cell and your text in the bottom one.

Also, I now understand what you want with your random cycling includes - it's a lot easier than what I first thought you were asking for. I'll post some code for doing what you want a little later.
Garin
"Devil in disguise"
Regular
on 18/09/2008 at 1:10:07AM
Total Posts: 1743
Not sure what your problem is, use <br/> if it works.
Machie
Regular
on 17/09/2008 at 11:54:56PM
Total Posts: 10891
Garin I'm stuck and need your help :( I have a simple div box and I want to have text and an image in it (text on top, image below). How do I go about doing that? In the old days I just put in <p> or <br>, but I want to do it correctly. How about wrapping <p> around the iamge is that correct?
Machie
Regular
on 16/09/2008 at 3:05:03PM
Total Posts: 10891
Yeah I much prefer to keep it simple and not go overboard. I suppose I should use them only when I know I will be making changes rather than incase I need to make changes like a "contant me | sitemap" menu at the top, I don't think I need to change that much if at all. Thanks Garin.
Garin
"Devil in disguise"
Regular
on 16/09/2008 at 2:55:09PM
Total Posts: 1743
Theoretically, theres no limit.  Hopefully though if you have too many includes then common sense should kick in and you'll realise you need to reorganise.

How many is too many though?  Depends who you ask.  Personally, 5 is about my limit but admittedly I'm efficiency driven when it comes to coding.
Machie
Regular
on 16/09/2008 at 2:32:29PM
Total Posts: 10891
I don't suppose there's some kind of limit for how many of these includes I can use. I think I wouldnt need more than 10 on each page. I'm mainly using them for things like menus, header, footer and things to go in the sidebar.

Talking of the sidebar, do you think its a good idea to have an empty include? Lets say I put this at the bottom of my sidebar <?php include('temp.php'); ?> and leave the php file blank. But then I decide run a competition for a few months and put it in the temp file without having to go through all my pages and add a new code.
Garin
"Devil in disguise"
Regular
on 12/09/2008 at 1:29:41PM
Total Posts: 1743
Machie wrote:
> Is it okay if I put them all away in a separate folder? I like
> to keep everything tiny.

You can do but dont go crazy with separate folders as further down the line you might start having fun with include paths.
Machie
Regular
on 12/09/2008 at 11:01:16AM
Total Posts: 10891
Yeah sorry about that I'm terrible at explaining things ^^; I should have said a random include with each page reload. Though I would probably use it for texts+images rather than (search/newsletter) forms.

I'm about to test this php include for the first time. I wonder if I should see the php include as a way of importing code rather than a piece of the page. So for my "footer.php" do I bother with the whole "<html><body> etc. and link to my css, or just a blank .php file with the code that I want to import, nothing else. I'm guessing its the latter, so all I need is to put the footer div on its own.

Is it okay if I put them all away in a separate folder? I like to keep everything tiny.
JimTheDog
"Woof Woof"
Regular
on 12/09/2008 at 10:03:39AM
Edited: 12/9/08 10:12
Total Posts: 19
if by 'rotation' Machie means a random include (from a pre-defined list) is shown after each page load then I agree that is not a big job but to cycle through several includes on a time limit without re-loading the page is a bit trickier - mind you I am by no means a pro programmer.

The cycle element of this problem also brings up the question of what to do when/if someone enters the form - it'll obviously have to stop rotating.

Remembering the last include is a simple job of adding a session var then reading it and using the value to choose the next include.

...but like i said above i didn't read Machie's request as wanting a different include per page load. I'll be interested to see if somone (for 'someone' read 'someone who know's what they are doing') can work up a solution.
Garin
"Devil in disguise"
Regular
on 11/09/2008 at 9:43:23PM
Edited: 11/9/08 21:43
Total Posts: 1743
Machie wrote:
> Garin (or anyone else), this php include thingamajigger. Is it
> possible to have a rotating one or is that not possible?

Most things are possible, its only a matter of how many lines of code to do it. :)

The problem with genuine rotation is that you need to remember what the user saw last which isnt difficult just needs a few lines of code dotted around your site.  Even easier is just random includes because its unlikely the user will notice rotation anyway.
Machie
Regular
on 11/09/2008 at 7:59:49PM
Total Posts: 10891
Aw that's okay then Jim, it's more of an added bonus really, so it wouldnt bother me if I couldnt do it ^^ Have a great holiday though, where you off to by the way? Talking of holidays this work is for a travel website of mine.
JimTheDog
"Woof Woof"
Regular
on 11/09/2008 at 7:01:53PM
Total Posts: 19
## Machie - I see what you're after. It can't be done with straight php (or certainly not the rotating/cycling without a page re-load) but I perhaps it can be done with the inclusion of a bit of Java code instead). I'll look into it - but I'm going on holiday tomorrow so can't guarantee a quick response (If I take my laptop with me my missus will NOT be best pleased).

JTD
Machie
Regular
on 11/09/2008 at 6:42:59PM
Total Posts: 10891
JimTheDog wrote:
> ## Machie - what do you mean by rotating?

Hello Jim :) I was wondering if it was possible to have a rotating php include. Similiar to a rotating banner, but I want it to rotate php include files. So in my sidebar I'd want it to rotate between a newsletter sign up form and a site search. Do you know if thats possible at all?
JimTheDog
"Woof Woof"
Regular
on 11/09/2008 at 6:10:41PM
Total Posts: 19
## Machie - what do you mean by rotating?
JimTheDog
"Woof Woof"
Regular
on 11/09/2008 at 6:07:33PM
Total Posts: 19
I agree with Eccles in that Dreamweaver (I use DW8) creates loads of unecessary code which you can learn little from as a beginner - but only when you use the DW automated processes/wizards.

I'd also go as far to say that if you don't care about how DW creates the PHP code and you just 'want it to work' then there's no reason to avoid it either - your approach to how much want to understand what you're doing will dictate how you use DW.

If you're serious about learning PHP then the best advice I can give you as a first step is to get hold of a copy of 'PHP for Dummies'. PHP For Dummies also walks you through your first connections to a MySQL database - which Freeloa supports.

Once you understand the basics of PHP then you are able to write your own code directly into Dreamweaver - because don't forget you're also going to need a graphical web site designer for your HTML elements.

I also regularly visit an excellent site 'php.net' which gives loads of examples and code titbits for a lot of PHP functions.

I hope this helps.
Machie
Regular
on 11/09/2008 at 10:44:03AM
Total Posts: 10891
I agree with Eccles. I do it old school, inside notepad.

Garin (or anyone else), this php include thingamajigger. Is it possible to have a rotating one or is that not possible?
Eccles
"Aargh! Broken..."
Staff Moderator
Send a message
on 11/09/2008 at 10:04:23AM
Total Posts: 424
I would avoid programs like Dreamweaver that automatically generate code for you.
It is confusing and the code is not very good to learn from (often it's very messy and includes a lot of stuff you don't need).
The best way to learn PHP or ASP is to write the code yourself using a good text editor like Notepad++ or PSPad. Dig around on Google, there are loads of PHP tutorials sites.

Regarding ASP, Freeola do not support this as it is a scripting language that runs on Microsofts web server software. We run Unix on our servers, which do not support ASP.
Tappet
"wots it all about"
Regular
on 10/09/2008 at 9:13:13PM
Total Posts: 30
do any of you guys use dreamweaver, i'm using dreamweaver cs3 which i thought would make all this php and asp simple or at least simpler, but it just seems to be simple yet more confussing!

can anyone tell me if dreamweaver is helpin me make things simple or should i be using some other process.
Tappet
"wots it all about"
Regular
on 10/09/2008 at 9:01:45PM
Total Posts: 30
hiya, im new to all this web design and have been teaching myself by messing around with a site and learning from my mistakes. mainly i find or see something on another website that i would like to do on my site, then search around for ll the help and scripts etc i can, ive got a good understanding of html but ive found that php and asp is the coding to be using, at the moment im trying to get my head around building the script, applications & forms etc but i think i'm in to deep cos i can't get anything to work, to be honest i'm finding it hard, you need this form that script and this snippet, i would love to crack this php and asp, but after trying different things out over the past few weeks i'm starting to wonder if freeola even support asp???? do you know??? by now you may be thinking i have not got a clue wot i'm talking about and your right cos all i know is wot ive worked out for myself and the only php application i successfully have running is a newsletter submission script, since ive been workin with asp ive been amazed at how powerful it could be if that makes sence, so yeh asp is the way to go and when you have cracked it can you let me kno how. many thx.
JimTheDog
"Woof Woof"
Regular
on 10/09/2008 at 7:02:08PM
Edited: 10/9/08 19:06
Total Posts: 19
Hi Digi,

I've just read through this thread and thought I'd chip in for what it's worth:

Apparently there is a school of thought which say you should only use pure php by echoing your HTML statements throughout your php page code but I've found there is little you can't achieve with a php statement strategically lashed in amongst your HTML - although it's really worth commenting your code well to avoid getting lost (use single quote within the php tags like <php 'comment here ?> ). My web site is a huge mish mash of HTML and PHP (with a MySQL db) so I'm getting to be a dab hand at coming up with 'creative' php solutions to my page problems. I'm not sure if I'm allowed to post web site urls here so please ask if you would like to see what I've done with a php site.

Anyway back the issue of includes, through trial an error I've found it's usually best to use <?php include_once("filename.php");?> becaue if you use <?php include("filename.php");?> on several pages and then include more than one of those pages on a single page you will get an error message.

I hope that makes sense.
Digitrader
"rodeado de tontos"
Moderator
on 10/09/2008 at 2:57:51PM
Total Posts: 810
Ok got it - <?include cheers.php>;? :)

Digi
Hmmm...
"Are you sure?"
Moderator
on 10/09/2008 at 11:42:09AM
Total Posts: 878
Yep - for Freeola sites, if the page contains PHP is needs to be called .php

Same for an SSI - the page needs to be .shtml





Search Freeola Chat
Digitrader
"rodeado de tontos"
Moderator
on 10/09/2008 at 11:09:08AM
Edited: 10/9/08 11:33
Total Posts: 810
so can you mix and match html and php ? if we have a page online thats a .htm file an I add the include ph thing? and so long as the include page has the .php extension it will show am i correct? eg I make a web page insert a table and in that table addd the line include menu.php for example - then to change a menu over the site all I do is change menu.php? is that how it works?


Digi

Update - just did a wee test and if I saved a page as .htm it didnt work, but saved both pages with .php ext ad yeah ot worked so i would need to rename all our pages with .php right?

Digi
Machie
Regular
on 09/09/2008 at 11:14:22AM
Total Posts: 10891
It works, thanks Garin ^^
Garin
"Devil in disguise"
Regular
on 08/09/2008 at 9:25:48PM
Total Posts: 1743
Server time, which may or may not report GMT.

You can try something like..

<?php putenv('TZ=Europe/London');echo date('l F j, Y');?>

Although whether that works will depend on php security settings.  PHP 5 has built in functions for setting the timezone but dunno if you're running 5 or not.
Machie
Regular
on 08/09/2008 at 8:13:38PM
Total Posts: 10891
If its that simple why couldnt I find it when I was googling for an hour :/

Thank you very much Garin. Although I just realised, is this set to my server clock or my computer clock? My server is in California, but I want it set to GMT. Is that possible do you know?
Garin
"Devil in disguise"
Regular
on 08/09/2008 at 7:37:56PM
Edited: 8/9/08 19:38
Total Posts: 1743
<?php echo date('l F j, Y');?>
Machie
Regular
on 08/09/2008 at 7:27:22PM
Total Posts: 10891
Does cjh still post on the forum? I need a php script to post the current date in this format "Monday September 8, 2008" so I dont have to keep changing it manually :)
Garin
"Devil in disguise"
Regular
on 05/09/2008 at 12:51:51PM
Total Posts: 1743
Machie wrote:
> Maybe I should write a beginners guide to php as I learn it.

I started writing one once upon a time, a totally thankless task. :)  I always thought cjh's beginners guide was pretty good.  A cut above everything I could write for certain.
Machie
Regular
on 05/09/2008 at 11:09:09AM
Total Posts: 10891
Well spotted Garin :) I miss Dr Jo, it's a shame he/she decided to leave :(

Maybe I should write a beginners guide to php as I learn it.
Garin
"Devil in disguise"
Regular
on 04/09/2008 at 11:42:13PM
Total Posts: 1743
If you look in the hints, tips and tutorials thread theres a link to a topic on this subject.
Machie
Regular
on 04/09/2008 at 8:15:45PM
Total Posts: 10891
That's some good advice, thank you McLong :) I'm already doing some tutorials and learning a bit of php. As long as I have the site structure the way I want it, I wont have any problems changing everything I need with php include. ^^
McLong
Staff
on 04/09/2008 at 7:58:21PM
Total Posts: 194
I'd be very surprised if most web developers with websites of a fairly substantial size don't use this tactic. It's pretty common knowledge as far as I'm aware.

And if you wanted to move a sidebar from the left to the right, then it's entirely possible, it just means that you'd have to update every page where you wanted it to happen. This could potentially take ages, but then in effect it's similar to a site re-design, which will always take a while to implement.

I recommend being entirely happy with your site layout before you put it all together!
Machie
Regular
on 04/09/2008 at 7:18:29PM
Total Posts: 10891
McLong I could kiss you. I didnt know it was that simple. It seems too good to be true, are you sure this is standard and what usually goes on?

Hmm it would make my job a lot easier but what if I wanted to move a sidebar like that one <- from the left to the right -> I wouldnt be able to do that in includes, I dont think :/ oh wait what if the whole page was an include like a template :) okay perhaps not

I'll do some research now and find out more. Thanks a bunch McLong :D
McLong
Staff
on 04/09/2008 at 6:03:02PM
Edited: 4/9/08 18:04
Total Posts: 194
It depends on what you're trying to achieve. A PHP include is a must-have if all pages on your site are of a very similar layout.

For example, the footer at the very bottom of every page ('Contact Us | Help & Support' links etc) on our interactive sites is exactly the same on every page, so therefore that part of the code, including the closing table, GetDotted search box and any other odds and sods is created in a separate file and then simply 'included' on all pages that need it. Therefore any changes that need to me made to any part of that section require only one file to be updated.

It's easy to do this, and if includes are all you need you don't need much knowledge of PHP at all. You only need to do the following:

1. Create a new file called something relevant to the code you will be creating, for example footer.php or navigation.html

2. Add the code that you wish to include to this file.

3. On the pages that you wish to include this file just type <?php include('footer.php'); ?> exactly where you want this include to appear. Your files will need to have a .php extension for this include code to work though.

-------------------------

I believe .ASP is for use on Windows servers, and PHP for Linux servers. I've never used ASP, nor do I want to.

And I doubt very much you'd be able to learn PHP in a week!

Hope this helps...
Page 1 of 2 1 2 » Last »
 
Change Chat Area