Computer Science Canada

PHP Coding Difficulties 2

Author:  mario64mario [ Tue Jul 22, 2008 12:12 pm ]
Post subject:  PHP Coding Difficulties 2

I'm back, from the remains of 'PHP Coding Difficulties'. I've completely wiped out the ftp with the design I had, and re-wrote new and much more basic coding. ALAS, the site still remains the same. The background image covers the rest of the site. Here's all the code I have.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Style.css

body {
margin: 0px;
padding: 0px;
text-align: center;
}

td.menu {
border-width: 1px;
border-top: 0px;
border-style: solid;
border-color: #000;
}

td.content {
border-width: 1px;
border-top: 0px;
border-style: solid;
border-color: #000;
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Index.php

<?php include("layout/top.php"); ?>
Content
<?php include("layout/bottom.php"); ?>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Top.php (header)

<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css" />
<title>Test Page
</head>
<body>
<img src=layout/banner.png><center>
<tr><td class=content>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Bottom.php (footer)

</table>
</body>
</html>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Can anyone help me with this?

Author:  DemonWasp [ Tue Jul 22, 2008 2:37 pm ]
Post subject:  RE:PHP Coding Difficulties 2

Well, you don't appear to have a <table> tag, nor do you appear to have </td> and </tr> tags. There is, technically, a <tbody></tbody> pair, but since most browsers let you ignore that, I'll ignore it too.

Again, try putting your code through the W3C validator, and using the <doctype .... > tag I mentioned in the other thread. This will force things to behave in a standards-compliant manner. (Oh, and for the sake of your own sanity, make sure you do everything in Firefox. IE is a nightmare.)

Kudos, though, the code you've posted now is WAY better than the code you had before. Leaps and bounds.

Author:  mario64mario [ Tue Jul 22, 2008 2:51 pm ]
Post subject:  Re: PHP Coding Difficulties 2

1. I've added the tags you've outline. Thanks.

2. I can't find the validator anywhere. Can you link me to it? Sorry... -___-

3. How do I use doctype again? ^__^''

4. Is Firefox going to help in coding issues, or the final result? 'Cause I'm stuck with IE until I get another computer, which won't be for at the very most 2 years.

Author:  octopi [ Tue Jul 22, 2008 3:02 pm ]
Post subject:  Re: PHP Coding Difficulties 2

You do know you can download and install firefox side by side with internet explorer right?

http://www.mozilla.com/en-US/firefox/

Author:  DemonWasp [ Tue Jul 22, 2008 3:08 pm ]
Post subject:  RE:PHP Coding Difficulties 2

1. No problem. If you install a better graphical editor, and be sure to indent properly, you'll discover things like that much faster. For a beginner, I would recommend Notepad++, but most professional programmers would reach for something like vim or emacs.

2. http://validator.w3.org/ , the free validation service. Note: if you make sure to include the DOCTYPE specified in #3, then this tool will be able to give you more information about how to fix your code.

3. Insert the following line as the first line of your top.php include:
code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


4. Firefox interprets HTML better than any version of IE, and it's MUCH better when dealing with CSS and any Javascript. It also has helpful plugins to help with web development, such as Firebug. If you need your site to be visible to people using IE, then you'll eventually have to make sure it works in IE (the biggest steps there are making sure it's 100% compliant - passes the validator with no errors) and in checking it yourself). Either way, it's easiest to develop in Firefox, then hack the result to work in IE.

May I ask why, of all reasons, you're stuck running IE and can't manage Firefox?

Author:  mario64mario [ Tue Jul 22, 2008 4:50 pm ]
Post subject:  Re: PHP Coding Difficulties 2

The admin of this CPU won't allow me to download another browser for the reason that programming is a 'hobby'. I'll probably get my own computer in a couple years for college or university, so I'll probably get it then.

Author:  Zeroth [ Tue Jul 22, 2008 5:05 pm ]
Post subject:  Re: PHP Coding Difficulties 2

mario64mario @ Tue Jul 22, 2008 1:50 pm wrote:
The admin of this CPU won't allow me to download another browser for the reason that programming is a 'hobby'. I'll probably get my own computer in a couple years for college or university, so I'll probably get it then.
... Gee, I suppose that the guys running Microsoft are doing it for a hobby? I bet this is your parents, not wanting you to download/install some random program. You should point them to this page showing that Firefox 3 was downloaded at least 8 million times in one day. http://www.spreadfirefox.com/en-US/worldrecord

Author:  mario64mario [ Tue Jul 22, 2008 5:24 pm ]
Post subject:  Re: PHP Coding Difficulties 2

Yea, they really wouldn't care. XD

Author:  octopi [ Tue Jul 22, 2008 7:22 pm ]
Post subject:  Re: PHP Coding Difficulties 2

Never used it but check this out
http://portableapps.com/news/2008-07-21_-_firefox_portable_3.0.1
Apparently doesn't require you to install app, just run it.

Author:  mario64mario [ Tue Jul 22, 2008 9:06 pm ]
Post subject:  Re: PHP Coding Difficulties 2

So it stays on the USB key, and when you take the key out, the original browser is used as it were?

Author:  octopi [ Tue Jul 22, 2008 9:08 pm ]
Post subject:  Re: PHP Coding Difficulties 2

Yes, its just like a program you'd run, it runs off the usb key as far as I know, like I said I've never used it, you'll have to take a better look at the site and figure it out.

Author:  mario64mario [ Tue Jul 22, 2008 9:11 pm ]
Post subject:  Re: PHP Coding Difficulties 2

Alright, I'll look into it further. Thanks for the referal.

Author:  jeffgreco13 [ Wed Jul 23, 2008 8:49 am ]
Post subject:  Re: PHP Coding Difficulties 2

That's pretty cool that firefox portable...

K but about your problem mario64... according to this NEW code u submitted there is not background image being loaded.

In your img and class make sure u sure quotation marks ( " ).

In the styles for td.menu and td.content, neither have a background image or colour specified. Meaning it will be transparents to the background image.

And let's get one thing straight, the background image is the BACKGROUND image so unless you're not making it a background image to your site,
IT IS NOT OVERLAPPING YOUR MATERIAL. You just might have colour conflicts (black on black).

I'm also pretty sure I told you to start practicing closing a tag AS SOON as you open it then write then content between them. This ensures you don't forget to close things like the </tr></tr></center> tags u missed.

Author:  mario64mario [ Wed Jul 23, 2008 10:01 am ]
Post subject:  Re: PHP Coding Difficulties 2

I'll have lots of time to practise that in September. I have computer science class, and we're using Turing. I think we might go into Java a bit as well.

I've erased the background image, and it no longer shows it. It only shows a blank page.

I think the file names of the images are corrupting the page. Would extension have an effect? Should I change them from PNG to JPEG?

Author:  DemonWasp [ Wed Jul 23, 2008 12:38 pm ]
Post subject:  RE:PHP Coding Difficulties 2

The extension of a file name is used for the sole purpose of discovering what kind of file it is (at least on Windows and largely on the Web). So: If you have not changed the type of contents in the file, do not change its extension.

Even if you were to change the .JPG on the end to .PNG, that wouldn't make it a PNG image - it'd make it a broken file, since trying to read JPG data as PNG doesn't work...at all.

I also have no idea what you mean by "file names of the images are corrupting the page", since that doesn't seem remotely possible.

Your page will display exactly as you tell it to. If you start talking gibberish at it, it will display gibberish. Check that your code is well-formatted (ie indent your code), then post it here, using < syntax="html" > < /syntax > around the whole thing. We will help you to make sure you're telling the computer exactly what you want.

Author:  mario64mario [ Wed Jul 23, 2008 3:20 pm ]
Post subject:  Re: PHP Coding Difficulties 2

I know about extensions, thanks.

What I meant by the file name, is becuase as long as the original 'bgpixel.png' exists in the FTP, it will display on the site, even though I haven't called upon it in my code.

Author:  DemonWasp [ Thu Jul 24, 2008 8:06 am ]
Post subject:  RE:PHP Coding Difficulties 2

Have you made sure that you've uploaded your new source? Images will not show up in a webpage unless you explicitly tell them to, so I'm guessing your old code is what you're seeing on the page, rather than your new code.

Author:  jeffgreco13 [ Thu Jul 24, 2008 8:32 am ]
Post subject:  Re: PHP Coding Difficulties 2

You can have about 1002345506 pictures on your FTP in the same directory as your HTML or PHP pages and unless they are called upon you will NOT see them displayed on your page.

Maybe you arent overwriting your source like DemonWasp said or maybe you have a little disaster going on in your code where that you're calling pictures (<img> <body background> or whatever).

Author:  mario64mario [ Thu Jul 24, 2008 10:21 am ]
Post subject:  Re: PHP Coding Difficulties 2

The only image I'm calling upon in my code is 'banner.png', and all of my previous code has been deleted.

Author:  DemonWasp [ Thu Jul 24, 2008 10:29 am ]
Post subject:  RE:PHP Coding Difficulties 2

Do you have a URL you can point us to, so we can see things for ourselves?

Author:  mario64mario [ Thu Jul 24, 2008 3:25 pm ]
Post subject:  Re: PHP Coding Difficulties 2

URL to what? The site? http://smb.zeldaoracles.net

Author:  Zeroth [ Thu Jul 24, 2008 3:36 pm ]
Post subject:  Re: PHP Coding Difficulties 2

... where is the index.htm, or index.html?

Author:  mario64mario [ Thu Jul 24, 2008 6:23 pm ]
Post subject:  Re: PHP Coding Difficulties 2

http://smb.zeldaoracles.net/wp-content/themes/tlom1/index.php

Author:  Zeroth [ Fri Jul 25, 2008 12:40 am ]
Post subject:  Re: PHP Coding Difficulties 2

I don't think you understand...

when I go to smb.zeldaoracles.net, the web server, which looks like, from the response header, to be Apache 1.3.4(outdated btw, with severe security flaws iirc), will look for an index.* in the root directory of the web visible section of the disk. Typically on a *nix-style server, that is /var/www/.

You can tell your webserver to serve a specific file, but thats a bit beyond my abilities. What I see, thanks to the magic of Firebug... that your server responds with a blank page. A page needs to be served at the root, in some way, to tie it all together. You can't link directly to an index.php in a wordpress theme folder. The index.php needs to be called within an "enviroment" which certain variables exist. The root wordpress page should do this for you. It looks like the wordpress install was bungled, but I could be mistaken.

Author:  DemonWasp [ Fri Jul 25, 2008 8:11 am ]
Post subject:  RE:PHP Coding Difficulties 2

I'm getting a big ol' PHP failure when I visit your extended URL there. Did you actually make sure you can see the page?

Author:  jeffgreco13 [ Fri Jul 25, 2008 8:49 am ]
Post subject:  Re: PHP Coding Difficulties 2

I too am getting a large error. Multiple ones actually. Ok enough tip-toeing if you need help post your entire code.

Stylesheets, PHP and HTML. And use code tags

I don't need to tell you but there's a good chance that a small error in the PHP can throw off your HTML and CSS.

Author:  mario64mario [ Fri Jul 25, 2008 9:11 am ]
Post subject:  Re: PHP Coding Difficulties 2

Style.css
code:

body {
margin: 0px;
padding: 0px;
text-align: center;
}

td.menu {
border-width: 1px;
border-top: 0px;
border-style: solid;
border-color: #000;
}

td.content {
border-width: 1px;
border-top: 0px;
border-style: solid;
border-color: #000;
}


Index.php
code:

<?php include("layout/top.php"); ?>
Content
<?php include("layout/bottom.php"); ?>



Top.php (header)

code:

<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css" />
<title>test Page
</head>
<body>
<img src=layout/banner.png><center>
<tr><td class=content>



Bottom.php (footer)

code:

</table>
</body>
</html>



The reason you're getting errors on index.php is becuase it's not recognising or it can't find the files top.php and bottom.php. I'm debating whether I should put them in the theme's folder or not. Turing usually requires all files called upon to be in the same folder, but this is the internet. >.>

Author:  octopi [ Fri Jul 25, 2008 9:36 am ]
Post subject:  Re: PHP Coding Difficulties 2

http://manage.magnify.ca/htaccess.zip

Put the file contained inside this zip into your main folder, it will ensure that php errors are on, so you'll see what your problems might be.

Author:  Zeroth [ Fri Jul 25, 2008 9:41 am ]
Post subject:  Re: PHP Coding Difficulties 2

well, index.php, accessed through that extended url, will look in http://smb.zeldaoracles.net/wp-content/themes/tlom1/layout/ for top.php and bottom.php. If however, its supposed to be this... http://smb.zeldaoracles.net/layout/top.php
and http://smb.zeldaoracles.net/layout/bottom.php which does in fact give the pages you wanted, then you need to link to /layout/<name>.php

Author:  Zeroth [ Fri Jul 25, 2008 9:43 am ]
Post subject:  Re: PHP Coding Difficulties 2

Oh, and good HTML practices is to do src="/layout/banner.png". You've been accessing non-existent files the whole time.

Author:  DemonWasp [ Fri Jul 25, 2008 9:56 am ]
Post subject:  RE:PHP Coding Difficulties 2

Turing is really dumb about letting you link things in. Don't use their design for anything but learning the basics - it's not a standard, and not particularly great in a lot of areas.

It looks like you just need to fix some links. I don't know what your setup looks like, so I can't really help you with that. I will say, however, that using relative links is a better ideal than absolute links...so instead of "http://www.smb.zeldaoracles.net/wp-content/themes/tlom1/style.css", I would recommend "wp-content/themes/tlom1/style.css" or similar. This makes it easier to test on your home machine, then just upload the completed / testing version.

Quick note: It's not valid to have a <table> tag in the <head> section. The <head> section is just information about the page, and what the browser should do in the background. The <body> section is what you're looking for - the section that describes what the browser should show.

Author:  jeffgreco13 [ Fri Jul 25, 2008 10:39 am ]
Post subject:  Re: PHP Coding Difficulties 2

Yes absolutely your paths are incorrect so ill take you thru a little tutorial on them...

This path goes to a file in the SAME directory as the file that's calling it (just the filename)
Quote:
<img src="filename.jpg">


This path goes to file within a folder WITHIN the folder that the current file resides (no backslash in front)
Quote:
<img src="foldername/filename.jpg">


This path directs to your root directory, for example if your root is http://www.sitename.com/ and your within a couple folders this takes you right to the top (the backslash in front of the filename)
Quote:
<img src="/filename.jpg">


And finally this path will take you up one folder from where you are. So say page.php is in /folder1/folder2/ but you want to access a picture in /folder1/ you do this (the 2 periods tell the browser to look one folder up)
Quote:
<img src="../filename.jpg">


Well there's my brief tutotial on paths have fun.

Author:  mario64mario [ Fri Jul 25, 2008 12:47 pm ]
Post subject:  Re: PHP Coding Difficulties 2

Thanks, everyone.

@ octopi - I just upload the contained file into the FTP?


: