|
#1
|
||||
|
||||
Basic PHP & MySQL Tutorial
This guide is for those who know nothing or little about PHP and MySQL.
1. Hosts, Databases and Other Info Places like Freewebs and Geocities don't support databases and PHP files, so you have to get a little creative. There are plenty of free and paid hosting out there for you to use that do support PHP/MySQL but finding them can be a hassle. So I'll give you some personal recommendations. Free: www.000webhost.com Paid: www.webhostingpad.com www.godaddy.com WBH is the only paid host I've ever used but they're extremely helpful and have tons of features for a very decent price. Anyways, my suggestion for free hosts is 00webhost but I would NOT suggest Byethost because they don't support a couple things that are required. There are others out there, these are simply the ones I'm familiar with. Now, once you've got a host down lets cover some other basics, Databases! A database is where all the information for your site will be stored. It'll be stored in detailed tables that can be added to, deleted from and updated at pretty much any point in time. Web Hosts will have specific directions as to how to set up a database, and make sure you copy down any information, such as the Database Name, the Database User and Password and so forth. This will come in handy when connecting to the Database. Now the Rusnak Script comes with a pre-installation, so you input the information where it goes and then you'll be able to connect to your database automatically as it's already coded into each page(Just be sure to use the 'blank.php' template when making new pages). If people ask I'll show how to code a connect script but for now lets stay simple. Once connected to a database, you can access it by coding MySQL 'Queries'. Basically your telling the database to get, add, delete or update information. There are many useful functions that can be done but for now those are the basics. When using PHP, similar to HTML you must save it as a different document type. When saving an HTML file, you save it as .html, although if your saving a file with php you have to save it as .php. You can edit PHP code in Windows Notepad, or download a better editor. My personal favorite is Notepad++, although if you want a debugger(a check that finds mistakes in the code) PHP Designer 2007 is a pretty good program. The best way to learn any code, including PHP is to get in there and figure out what's going on with a script and try to change a couple things. So let's get to scripting. 2. PHP Basics Before we get into MySQL let's get into some PHP basics. A quick vocab word: Syntax. Syntax refers to the grammar and structure of the code. If you have a syntax error, it's probably because you forgot a ';' or a '}' in the code. The first things you should know about PHP is the tags. You have to use these tags within a PHP file in order for the PHP to work. PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
Alright now that we know some basic PHP code and how to write it, lets move on to something a little more useful. If-Else Statements. PHP Code:
For organization purposes, there is something called comment lines, and comment blocks. Most scripts only bother with comment lines. When you get a code that's thousands of lines long, comments are very helpful for finding what your looking for. Comment lines can say a simple statement about the code following it. PHP Code:
PHP Code:
Congratulations, you know some PHP basics! 3. MySQL Basics MySQL goes hand in hand with PHP quite well. While there are different ways of running a query, this is the one I'm most familiar with. These queries can be written directly into the PHP code like this, PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
And there you have it. The basics of PHP and MySQL! Last edited by Kaeliah; 01-30-2011 at 12:45 PM. |
#2
|
||||
|
||||
Very helpful tutorials Kaeliah, I know you will make one. This should be good for aspiring PHP learners, lets hope we will have more PHP programmers in future.
*stickied* Hall of Famer
__________________
Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site. |
#3
|
||||
|
||||
Thanks Famer.
|
#4
|
||||
|
||||
You are very welcome. I will wait till you finish the loop tutorials and then post my tutorials for arrays.
__________________
Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site. |
#5
|
||||
|
||||
Good because I HATE arrays.
|
#6
|
||||
|
||||
lol...
Actually I dont see arrays or classes being used in RA, so guess they are not really required to work on modifications of this script. XD
__________________
Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site. |
#7
|
||||
|
||||
...Kae, this is brilliant.
This tutorial REALLY helps. I couldn't figure ANYTHING out about MySQL before now. (Mostly because w3school's MySQL tutorial is a strange-ish blur) |
#8
|
||||
|
||||
Yay I'm glad I could help. And ADORABLE avatar!!!
|
#9
|
||||
|
||||
Found a very interesting article about Mysql commands in PHP, looks like it will help a lot:
http://www.createafreewebsite.net/phpmysql/alter.html
__________________
Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Basic Browser Game Tutorial using Smarty and Bootstrap | Kesstryl | Programming and Game Development | 3 | 10-29-2014 11:15 PM |
I need basic coding help | Moontides | Feedback and Suggestions | 23 | 05-28-2014 02:54 PM |
Intermediate PHP & MySQL Tutorial I | Kaeliah | Tutorials and Tips | 4 | 01-31-2011 04:20 PM |
PHP/MySQL Tutorial | HIddenPanda | Tutorials and Tips | 0 | 01-27-2011 05:30 PM |
My BASIC programs | SleepWalker | Other Chat | 0 | 04-05-2010 09:37 AM |
What's New? |
What's Hot? |
What's Popular? |