MySQL database

mttheopfor89

New Member
Messages
14
Reaction score
0
Points
0
I need to use MySQL for a login system but I do not have the info for it. The video I was watching said that the hosting services would provide it. May I please have the info?
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
The link for your stylesheet should be:

HTML:
<link rel="stylesheet" type="text/css" href="/stuff/style.css" />

Likewise, your image links should be:

HTML:
<img src="/logo.png" border="0" alt="theopfor" />

Note the leading slash, which makes the link relative to your public server root. The entire path "/home/theopfor/public_html" lives above your web root -- it's not visible to the browser crowd.
 

mttheopfor89

New Member
Messages
14
Reaction score
0
Points
0
If I use the / like you did my page gets filled with: Warning: include() [function.include]: Failed opening '/stuff/doctype.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/theopfor/public_html/login/login.php on line 1

Any other way? I am using the PHP include() function in all my pages.
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
Ah, a true n00b. You need to understand that there are two different kinds of links going on here. Your PHP include() and require() statements run on the server, so they need to use the paths applicable on the server. Your style sheet and image links are fetched separately by the browser when your page loads, so they need to use the web address. So---change the links I advised you to change, and put your include()s back the way they were.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Another way of thinking about it is URLs and filesystem paths belong to different namespaces, similar to how variable and function names are in different namespaces in PHP, as are HTML element IDs and classes. Street addresses and phone numbers provide another example.

Starting a new thread is the appropriate thing to do when you've got a new topic. That way, people who come across a thread while working on a problem they're facing don't have to go through irrelevant information.
 

mttheopfor89

New Member
Messages
14
Reaction score
0
Points
0
Ah, a true n00b.
Yeah... I need to still work on some stuff I guess...

So... To late to start a new thread? Sorry for being quite n00by. Is there any ways to fetch stuff from one folder and put it on the page? Here is kinda like a tree to explain what I mean:

-stuff
--style.css
--header.css
--continued on
-login
--login.php
-index.php
-projects.php
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
No need to apologize for being a novice. What's important is that you make an effort (don't be the bad kind of lazy) to learn, and use your head.

It's never too late to start a new thread if you've got a new topic.

Is there any ways to fetch stuff from one folder and put it on the page?

This question isn't intelligible. What do you mean by "fetch"? The normal meaning is to download, usually using file transfer software. How do you want to "put it on the page"?

Nested lists are a good way of showing hierarchies. For example (spaces added in brackets to prevent the text from being interpreted as BBCode & to preserve whitespace; actual code has no spaces in BBCode tags):
Code:
[ list]
[ *]stuff/
  [ list]
  [ *]style.css
  [ *]header.css
  [ *]continued on
  [ /list ]
[ *]login/
  [ list]
  [ *]login.php
  [ /list ]
[ *]index.php
[ *]projects.php
[ /list]

Which produces:
  • stuff/
    • style.css
    • header.css
    • continued on
  • login/
    • login.php
  • index.php
  • projects.php
 
Last edited:

mttheopfor89

New Member
Messages
14
Reaction score
0
Points
0
Okay. The include() function takes a file's code and put's it on the page client side right? Well I am requiring to use my CSS file for my pages that are also in different folders. Well what eseller said was that I couldn't access something from the very beginning of my website's directory. So now I am clueless on how to use the include() function to use these files on pages from different folders.

  • stuff/
    • style.css --This needs to be accessed
    • header.css --This needs to be accessed
    • continued on --This needs to be accessed
  • login/
    • login.php --This file needs to access the contents in the stuff folder
  • index.php
  • projects.php
 
Last edited:

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
As misson said, there's no need to apologize for being a novice -- we all were at one point. Going from novice to intermediate is a simple matter of R&D ("rip off and duplicate"), and one of the most powerful R&D tools is the View->Source (or View page source) feature in your browser, combined with things like the Developer Tools in Google Chrome or the Web Developer Toolbar add-in for Firefox.

Your PHP code only exists on the server. It is all resolved into HTML* before being sent to the browser. The browser never gets to see your include() statements; it is only shown the result after the include() has been carried out. A simple example: let's say you have this file, named "head.inc.php", and it lives in the directory "/home/myname/public_html/includes".

PHP:
<!DOCTYPE html>
<html>
   <head>
      <title>The Site Title</title>
      <link rel="stylesheet" type="text/css" href="/css/common.css">
   </head>

and this file, called "test.php", living in "/home/myname/public_html"

PHP:
<?php
include("/home/myname/public_html/includes/head.inc.php");
?>
   <body>
      <h1>Hello, world!</h1>
   </body>
</html>

The server puts the two together before sending them to the browser. When you open "test.php" in the browser and view the source, you will see

HTML:
<!DOCTYPE html>
<html>
   <head>
      <title>The Site Title</title>
      <link rel="stylesheet" type="text/css" href="/css/common.css">
   </head>
   <body>
      <h1>Hello, world!</h1>
   </body>
</html>

The server carried out all of the PHP instructions before sending the page to the browser. Notice that the stylesheet still appears as a link in the browser. It's the browser's job to ask the server for the stylesheet and apply it to the HTML page it received.

The browser doesn't know (and shouldn't know) anything about the server's file system. All it knows is that it is currently looking at a location called "http://server.domain.tld/test.php", and that the link to the stylesheet is "/css/common.css". It has a set of rules to follow when making requests, and one of those rules is "if the link starts with a '/', then I keep the protocol, port and domain parts of the URL I'm looking at now". So to get the stylesheet, the server asks for "http://server.domain.tld/css/common.css".

The same thing happens for images -- the browser has to get the images from the server after it receives the HTML page that your PHP creates.
____________
* I'm deliberately oversimplifying here; you can also use PHP to create images, stylesheets, Flash, etc., on the fly, but that's beyond the scope of this question.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
The include() function takes a file's code and put's it on the page client side right?
Server side (as essellar explains), not client side.

Well what eseller said was that I couldn't access something from the very beginning of my website's directory.
What does he say that you take to mean this? By "beginning of [your] website's directory", do you mean the document root, the "first" folder in the document root (there's no unique ordering of siblings in a filesystem, so "first" isn't well-defined), or something else? include can access any file on the filesystem, limited only by filesystem permissions, safe mode checks (if enabled) and the open_basedir configuration directive.
 
Last edited:

mttheopfor89

New Member
Messages
14
Reaction score
0
Points
0
Okay it still is glitchy. Now after adding /home/theopfor/public_html/ before my stylesheet index.php, and projects.php's stylesheet is not working. login.php still has it's include errors.
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
I've tried to explain this before: the "/home/theopfor/public_html" part needs to be left out of the link to the stylesheet and images -- those things happen in the browser. You need to include that path in the include() statements, since that happens on the server. So do this for your PHP includes:

PHP:
include("/home/theopfor/public_html/filename.php");

but do this for your stylesheet link:

HTML:
<link rel="stylesheet" type="text/css" href="/css/filename.css">
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
On the center-aligned pages, you have a <div align="center"> that is never closed. Make sure that all of your HTML tags are closed.

You shouldn't put the alignment into the HTML in any case; HTML is a language that describes the structure of a page. Use the CSS to control the page's appearance. That way, if you want to make changes to your site's appearance at a later date, you simply need to change a single stylesheet rather than editing all of the HTML/PHP pages.
 

mttheopfor89

New Member
Messages
14
Reaction score
0
Points
0
All my tags are closed. CSS file aligns everything with an id of content to the left. All my div tags currently have an id of content. Well all except for my header and footer but those I doubt I will change. Even if I do need to change them I just have to change one file just like I would a CSS file. The main body is the part of the webpage that has the problem.
 
Last edited:

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
This is the HTML source for "projects.php":

HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd"> 

<html>
<head>
<meta name="description" content="theopfor! A site for miscellaneous things." />
<meta name="keywords" content="theopfor,pcriot" />
<title>theopfor</title>
<meta name="google-site-verification" content="_M9LWyDLBayWBW6k-Wd5Dk21X5rD26MuMssvHQOxlu8" />
<link rel="stylesheet" type="text/css" href="/stuff/style.css" /></head>
<body>
<div type="header" align="center">
<div type="content" align="left">
</div>
<a href="http://theopfor.pcriot.com/"><img src="/stuff/logo.png" border="0" alt="theopfor" /></a>
<hr />
<div align="left">
|<a id="mainlink" align="left" href="http://theopfor.pcriot.com/">Home</a>|
<hr />
</div>
<div type="content" id="content">
<p id="standard">Welcome to the project page!</p>
<p id="standard">This is what I do on my spare time! Unfortunately you do have to download 
some of this stuff but it is virus free.</p>

<dl id="standard">
<dt><a href="stuff/Keyboard_Warrior.exe" target="about:blank">Keyboard Warrior</a></dt>
<dd>A text turn based game. My very first game ever programmed written in C++. The AI is broken so it is
impossible to win but kinda interesting I guess.</dd>
</dl>
</div>

<div type="footer">
<hr />
<p>Expect some delays for new pages. Currently having alignment and styling issues. <br />If you need to contact us please email theopfor@theopfor.pcriot.com thank you!</p>
</div></body>
</html>

This:

HTML:
<div type="header" align="center">

is never closed. (And "type" isn't a valid attribute for the <div> element.)

And the advice to keep your appearance separate from your structure is being given by somebody with web experience that is only a couple of months short of the entire period during which HTML has existed. You might want to take it.
 
Top