Jump to content
OtakuBoards

PHP and MySQL


Guest Sean
 Share

Recommended Posts

[FONT=Arial]I understand that there are different variations to MySQL such as Apache and the likes, but, what I don't understand is how to use it. I've read up on it, I've looked at whatever I can to try and get further, but yet I am still lost.

I need to learn how to use and construct a database for an upcoming website I am creating and coding, and without the use of a database then it will be extremley difficult to use seeing as it will be a Web-Comic.

I do hope someone can help me come to terms with PHP and MySQL/Apache and the likes, and I will muchly appreciate it.

Thank you.[/FONT]
Link to comment
Share on other sites

  • 2 weeks later...
[font=Arial Narrow][size=2]Okay. MySQL is a database. A database saves data, and PHP [in this case] is used to retrieve it. Got it? But PHP doesn't have to be used just to retrieve MySQL. The two are complementary, but one isn't always essential for the other.

Generally, you'll have a MySQL dump code -- its the code that creates the tables so that the database can store the data. Then, you'll have PHP code and forms [just like HTML forms] which can be used to input data. [color=DarkOrange][b][url="http://www.daydreamgraphics.com/"]Daydream Graphics[/url][/b] [/color][DDG] has quite a few tutorials on it, including MySQL and PHP Basics.

As for PHP: It's another way to tell the webpage what to do. At its most basic level, people use it to include their layouts rather than having to paste the layout [I.e head /head tags, etc] onto the page. In the same way that External CSS sheets mean that you can have all of the pages linking to that -- so when you change it, the changes are reflected on everypage --, PHP includes mean that you can include your entire layout in just two tags -- and have the content in between.

For example:

[PHP]

Content Here



[/PHP]

What you do, is create a text file called "header" with all the stuff about the content in it, and one called footer, with all the stuff below the content in it. Every page you have needs to have the include tags in it. Save those pages as .php, rather than .html, and then upload them along with the header and footer pages. It'll pull out the information and load your layout on that page. So, when you come to change your layout, you can do it just by editing the header and footer pages.

A lot of sites use PHP for just this reason. [url="http://never-established.net/"][color=YellowGreen]My site[/color][/url] has PHP includes, as does [url="http://dead-seraphim.net/"][color=Gray]Alan's[/color][/url], [url="http://strawberry-princess.net/"][color=Red]Raina's[/color][/url], [url="http://wrappedinplastic.net/"][color=Blue]Tony's[/color][/url]...the list is endless, lol.

A couple of things, though: You'll want to make the layout in HTML before you PHP-ify it, as very few computers have the ability to view PHP without uploading it to the internet.

This stuff is very, very basic, though. Sean, I have the feeling you may have a problem with doing this site if you've never worked with PHP before. Matt, I'm not quite sure what help you need, but let me know and I'll see what I can do.

[b]EDIT -- [/b]Also, keep in mind that if it's in the include, it'll be in every page. So anything unique i.e. page content, goes between the include tags, because that is where your page would normally do.

The way the PHP works is that when you view the page, it will actually put the code in there, so you don't have to. Which means anything in between should be normal HTML -- you still need to include things like paragraph tags, etc.
[/size][/font]
Link to comment
Share on other sites

[quote name='Lady Asphyxia']Matt, I'm not quite sure what help you need, but let me know and I'll see what I can do.[/quote]
Well, what I really need help with is the code in the thread I wrote right after I wrote that reply. [url=http://www.otakuboards.com/showthread.php?t=48668]That thread is here.[/url]

I'm thinking that it might be some permissions issue im MySQL, but I don't know for sure.
Link to comment
Share on other sites

  • 2 weeks later...
Guest userdan
you forgot to mention another benefit of PHP:
Security.
When someone tries to view your source code(give it's a PHP page), it'll just show the text, not the source itself.
ie.
you put in
[php]
echo "test";
var $i;
$i="password";
echo "you can't see my password, n00b!";
?>
[/php]
And somone viewing your page's source will only see:
[code]
test
you can't see my password, noob!
[code]
Give, of course, you used html tags.XD
Link to comment
Share on other sites

[quote name='Lady Asphyxia][font=Arial Narrow][size=2]As for PHP: It's another way to tell the webpage what to do. At its most basic level, people use it to include their layouts rather than having to paste the layout [I.e head /head tags, etc] onto the page. In the same way that External CSS sheets mean that you can have all of the pages linking to that -- so when you change it, the changes are reflected on everypage --, PHP includes mean that you can include your entire layout in just two tags -- and have the content in between.[/size'][/font][/quote]

I am impressed Asphy. :) I didn't see you as one to pickup web design/art really...
Though why use a mixture of tables and divs on your site? Though off topic. :p

I hope the following helps as I think you are a bit confused Sean.

Okay PHP since about version 3.x(.2?) has moved beyond the realm of simple web "helper" and addition abilities and over 4.x and now 5.x branches has turned into a full OOP language very similar to C++. What this means to you Sean is not very much at all... Luckily the PHP community loves you and every one in the world who is interested in PHP by providing one of the best new user and developer manuals in existence, which you can find [url=http://www.php.net/manual/en/]here (clicky!)[/url]. Reading about and learning MySQL/PHP is your best chance of getting more work (if you are after web development money on the side) and enjoying web coding as these features are very advanced and leave you well on the way to knowing LAMP (google it!). Plus you will be able to do what you are talking about by following the examples in the manual. [b]So now you have no reason not to RTFM![/b] ..heh.

Though you don't seem to overly understand MySQL and what it has to do with PHP. SQL is a database accessing syntax and MySQL allows you to interact (phpmyadmin is a very good new user tool for this) with current generation databases via an open source SQL platform. PHPs involvement here is that it allows you to call databases using SQL from any SQL-compatible backend (normally MySQL) from _inside_ the webpage which you can read about in detail in the manual. This allows for a huge expansion of websites, instead of just injecting your headers and footers from an existing store (or your content) you can hold your whole website in a database (probably what you'd want for a comic) that is dynamically created every time some one loads it. This allows for easy editing through backends that you can create or that you tie in to existing Content Management Systems (CMS - google it!).

A note though, why reinvent the wheel? I'm rather sure there are several comic specific frontend/backend solutions available for free... Of course if there isn't you can write one and release it under the GPL so others can benefit. :D

2cents...

EDIT: Apache is a web server! It deals with the interaction of your web browser ([url=http://mozilla.org/]Firefox (clicky!)[/url] I hope!) and the server that your website sits on. It in effect serves (just like the nice ladies at your local coffee place - mmm coffee) the code and pre-scripted events to your browser so you can see them. Apache has a MySQL module that allows it to use SQL to interact with the servers database and the web pages code - so apart from that the two programs are completely different and independent of each other, the same applies for PHP.
Link to comment
Share on other sites

[quote name='userdan']Actually, Apache is a server to browser communicator(STBC), not a server, a server is a PC running apache.[/quote]
I believe this is just a complaint about the use of the term [b]server[/b]? If so I'm happy to replace [i]server[/i] with [i]service[/i] which is a far more apt description of Apache in this new "Gates Speak" world. Though if you really want a fight about it I have [url=http://en.wikipedia.org/wiki/Apache_server]Wikipedia (clicky!)[/url] and the [url=http://httpd.apache.org/]Apache Foundation and Project (clicky!)[/url] agreeing with my use of "Apache (web) Server".

Though I disagree that the box that a service runs on can be the only object/system that gets to use the term server.
Link to comment
Share on other sites

[COLOR=Indigo][SIZE=1][FONT=Arial][QUOTE=ForgottenRaider]I am impressed Asphy. :) I didn't see you as one to pickup web design/art really...
Though why use a mixture of tables and divs on your site? Though off topic. :p[/QUOTE]
Because, [i]smart-arse[/i], it's using a floating DIV on the left for the nav and another floating tag on the right for the content, By default DIV tags don't stretch when floating child elements hit the bottom of them. Obviously, tables do, thus they were used to house the content and nav DIVs. We could use specialist CSS classes, of course, but it wouldn't freaking matter because IE's a piece of **** and doesn't recognise them. There's your question answered. ~_^ *coded the layout*

Apache is web server [i]software[/i]. A server is a PC (or Mac, whatever) designed to run server software exclusively.[/FONT][/SIZE][/COLOR]
Link to comment
Share on other sites

Guest userdan
[QUOTE=Aiyisha][COLOR=Indigo][SIZE=1][FONT=Arial]
A server is a PC (or Mac, whatever) designed to run server software exclusively.[/FONT][/SIZE][/COLOR][/QUOTE]

Well, you got the first part right...A server is any bo which can be accessed through the internet, a server YOU were talking about is called a [B]dedicated server[/B].
Link to comment
Share on other sites

UserDan your comment discrediting Aiyisha post is inaccurate as her (just guessing? :p) definition of a server is completely correct. :) A computer server is [i]normally[/i] a computer that is running specific software for a specific area of a systems, it does [b]not[/b] have to be on the internet.

I agree with Wikipedia on what a server is:
(Following quoted from [url=http://en.wikipedia.org/wiki/Server]Wikipedia (clicky!)[/url])
[i]In computing, a server is:[/i]
* A computer software application that carries out some task (i.e. provides a service) on behalf of yet another piece of software called a client. In the case of the Web: An example of a server is the Apache Web Server, and an example of a client is the Mozilla Web Browser. Other server (and client) software exists for other services such as e-mail, printing, remote login, and even displaying graphical output. This is usually divided into file serving, allowing users to store and access files on a common computer; and application serving, where the software runs a computer program to carry out some task for the users. This is the original meaning of the term. Web, mail, and database servers are what most people access when using the Internet.

* The term is now also used to mean the physical computer on which the software runs. Originally server software would be located on a mainframe computer or minicomputer. These have largely been replaced by computers built using a more robust version of the microprocessor technology than is used in personal computers, and the term "server" was adopted to describe microprocessor-based machines designed for this purpose. In a general sense, server machines have high-capacity (and sometimes redundant) power supplies, a motherboard built for durability in 24x7 operations, large quantities of ECC RAM, and fast I/O subsystem employing technologies such as SCSI, RAID, and PCI-X or PCI Express.

[quote name='Aiyisha][COLOR=Indigo][SIZE=1][FONT=Arial]Because, [i]smart-arse[/i], it's using a floating DIV on the left for the nav and another floating tag on the right for the content, By default DIV tags don't stretch when floating child elements hit the bottom of them. Obviously, tables do, thus they were used to house the content and nav DIVs. We could use specialist CSS classes, of course, but it wouldn't freaking matter because IE's a piece of **** and doesn't recognise them. There's your question answered. ~_^ *coded the layout*[/FONT][/SIZE'][/COLOR][/quote]
Though dear one should not use tables for layout as they are designed for tabular data only. A mixture of (X)HTML/CSS is far better netiquette and makes sure that it is cross browser compatible with Firefox, Opera, and Microsoft Internet Explorer (MSIE). W3C standards outline the correct method for defining layouts and simpler (easier to follow) guides to using these standards are easy to find at places like [url=www.w3schools.com]w3schools (clicky!)[/url] and [url=www.htmldog.com]html dog (clicky!)[/url]. Anyway I was just interested in why they were used considering most of the page followed standards.

Now there is no point putting down MSIE as it is stock standard with all Windows installs so the people using it are to lazy or just haven't been educated in the dangerous risks of using it to switch to some thing better. So it is just a fact of life until the majority of the web makes the switch to newer browsers. Though just because it holds slightly over 80% of the browser market doesn't mean it is an excuse to be a lazy web coder and not adhere to standards; remember when Windows Vista is released it is expected that Firefox will take up to 60% of the market. Firefox isn't a fan of none web standards code. :p

[i]If double posting is not allowed please merge these two posts[/i]

[color=#4B0082]I'm sure you're competent enough to use quote tags manually and edit posts to add things later. Next time you can do it yourself. :p - [i]Desbreko[/i][/color]

I rather sure I am as well. :p
Link to comment
Share on other sites

[COLOR=Indigo][SIZE=1][FONT=Arial][QUOTE=ForgottenRaider]Though dear one should not use tables for layout as they are designed for tabular data only. A mixture of (X)HTML/CSS is far better netiquette and makes sure that it is cross browser compatible with Firefox, Opera, and Microsoft Internet Explorer (MSIE). W3C standards outline the correct method for defining layouts and simpler (easier to follow) guides to using these standards are easy to find at places like [url=www.w3schools.com]w3schools (clicky!)[/url] and [url=www.htmldog.com]html dog (clicky!)[/url]. Anyway I was just interested in why they were used considering most of the page followed standards.

Now there is no point putting down MSIE as it is stock standard with all Windows installs so the people using it are to lazy or just haven't been educated in the dangerous risks of using it to switch to some thing better. So it is just a fact of life until the majority of the web makes the switch to newer browsers. Though just because it holds slightly over 80% of the browser market doesn't mean it is an excuse to be a lazy web coder and not adhere to standards; remember when Windows Vista is released it is expected that Firefox will take up to 60% of the market. Firefox isn't a fan of none web standards code. :p

[i]If double posting is not allowed please merge these two posts[/i][/QUOTE]
The page validates. It adheres to web standards, and I've not encountered a rendering engine yet that chokes on it. It's IEs problem that the page needs hacks, not mine. If MS did their job properly the first time, it wouldn't have a problem. But they didn't, so, thusly, I will feel free to call IE a piece of ****.

I'm done with this though, because arguing with a geek about web standards is useless. They're useful, sure, but hey - noone cares what's under the hood as long as the page looks good and works. I'm not about to change Lady A's beautiful design just because of the web standards - web standards which look to be getting worse, as the A tag and IMG tag are being removed in XHTML 2.

Design > Code[/FONT][/SIZE][/COLOR]
Link to comment
Share on other sites

[font=Arial Narrow][size=2]I think Alan's opinion very much reflects my own. While I enjoy coding, I often find it frustrating and ridiculous, haha. For me, it's just a means to an end -- I'll use anything that works to get it to look the way I've designed it. I'm not going to compromise the integrity of the structure in order for the code to be considered perfect. Validation is important, definately, but since I design and then figure out how to code, often it's quite difficult to get it the way I want -- and that's when I enlist Alan. And since I actually use Firefox myself -- and have absolutely no problems with it -- then I'm happy. Coding is good in the sense that it's something for me to puzzle out. Unlike Alan, I don't know that DIV tags don't stretch, etc, and so it's a challenge. Mostly I just enjoy design and leave the 'heavy' work up to him, but I designed and coded my hosting site and now I'm coding my new layout, so while it can be difficult, it can also be rewarding, hee. And it's good practical knowledge to have.

As for PHP, I'm barely a beginner myself. I've done some messing about, but I often find it just a little tedious and with school I get to busy to get seriously into it. Perhaps next year I'll be more into it. ^_^


[Also, double posts are not allowed, so why don't you save a mod some trouble and just merge the two yourself (Edit> Copy Post B > Paste into post A, and then delete post B.). ^_^"]
[/size][/font]
Link to comment
Share on other sites

  • 2 weeks later...
[quote name='DjManix']just a thought....but isnt this thread steering down the off topic lane? anyways, your guys info has helped me alot too guys ^^[/quote]
With the hand break firmly on... :|
Glad you did learn some thing though. :)

For me code > design; though design should be dependant on good code!
Link to comment
Share on other sites

[COLOR=Indigo][SIZE=1][FONT=Arial][QUOTE=ForgottenRaider]With the hand break firmly on... :|
Glad you did learn some thing though. :)

For me code > design; though design should be dependant on good code![/QUOTE]
Too bad noone who visits a website cares about the code then. :)[/FONT][/SIZE][/COLOR]
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...