Misc Links
Forum Archive
News Archive
File DB
 

Ads
 

Advertisement
 

Latest Forum Topics
wow 56 k modems are
Posted by Red Squirrel
on Oct 14 2013, 11:52:23 pm

I Need A Program
Posted by rovingcowboy
on Sep 23 2013, 5:37:59 pm

having trouble witn lan
Posted by rovingcowboy
on Sep 23 2013, 5:40:56 pm

new problem for me
Posted by rovingcowboy
on Sep 23 2013, 5:54:09 pm

RBC Royal Bank
Posted by Red Squirrel
on Aug 13 2013, 6:48:08 pm

 

Php how-to for starters
Taking web design to the next extreme
By Red Squirrel


Like mentioned earlier, for php documents to work, you need to have a server with PHP enabled/installed. To install php, you can download it here at http://www.php.net. However, if you are running a Linux server, it should already be installed and working.

If you are running a windows server, it is quite tough to get it to work, and don't expect it to work well once it's working. (this IS windows we are talking about). For windows, I recommend you get a bundle package called Easy php so you don't have to go through trying to install it manually. It is an outdated version of php, but it works for a test server. But if you have the cash to build a dedicated server that will be used for only that and not worry about it's use (ex: parents' computer), no use having windows - put on a good Linux distro on it and install php and apache. I recommend Red Hat or Mandrake, especially if you're a Linux newbie like me.

PHP is often seen with mysql, it is recommended to have mysql as well. Most php scripts also require mysql to store data. But if all you are planning to do is program your own scripts, you can make them use file databases instead. MySql is simply another server side installation like php, but for databases. For example, here at Iceteks our forum is run by php, and the actual posts and other data is stored in a mysql database, including the currency info of the cybervillage. But it could also be put in files if it would have been programmed that way, by mysql is much more organized and fast which is why it is used for big applications such as forums.

When looking for a place to host a website, make sure you get php and mysql. If you're going to pay, you might as well get those features + more. Stay away from Microsoft servers; go with Linux and Apache. There's a windows version of apache, but it's still best to stick with Linux if you can.

Let's get coding!
Now that we are all set with a server and that you know more what php is, we'll move to coding. What's nice about php is that even though you are coding php, you can still code html. The php parser on the server will only parse php if you tell it to. To tell it, you simply put this:

<?php
code blah blah
?>


Anything outside of that is not parsed but simply sent directly to the client as it is. You can have as many php code parts as you want in your page. Also, in your apache configuration file, you can decide what file extensions will parse though php. If you plan to use php allot, you might as well add in .html and .htm so that even if you put php code in a .htm/.html file, it will still parse it. Parsing is simply the word used to say that the php is executed by the server and the execution result is sent to the client.

Our first script
Here is a simple script written with php:

<?php
echo("hello world"); //this is a comment

/* this is another comment */

?>


If you upload this to your server and open it, you should get the text "hello world". Also, two different type of comments have been added to show you how you can add comments to your code for your own needs. The first one is for single line comments, while the second one can be used for longer comments that take up more then one line.

You may ask yourself what the point of php is, since sure you can easily skip the php stuff and just write "hello world" and still get the same result. The next page will explain this to you, since there's WAY more to php then the echo() function!







Next Page
spacer
297463 Hits Pages: [1] [2] [3] [4] [5] 28 Comments
spacer


Latest comments (newest first)
Posted by halojoy on June 06th 2005 (22:36)
Yes, it is nice with scripts that does note produce notices.
isset is a good way to avoid this,
if you do not want to add a lot of code that sets 'empty' values for variables

Another way is to TURN OFF reporting of NOTICE
you add this, at top (beginning) of your php pages:
CODE
<?php

// Report ALL, but not NOTICE
error_reporting ( E_ALL & ~E_NOTICE );

// You will still get WARNINGS and other real ERRORS
// Notice is not an error, just a note
// To not have to add it in all your pages you can make it a line in 'config.php' ,
//  if you have such a file, that is included by php pages
?>
I use E_ALL = reporting with notices only when working with my code
When I am finished and put my code on website, I Turn Notice OFF, using that line.
I do not want to scare my visitors laugh.gif

spacer
Posted by Red Squirrel on November 11th 2004 (14:13)
You need to run it off a webserver that has php installed.

So you would type http://serverhost/script.php


spacer
Posted by Red Squirrel on October 10th 2004 (16:32)
It means you have a syntax error in your mysql query, unfortunatly mysql is not very helpful at telling WHAT the error is, so you'll have to figure that part out. Post the query and maybe I can look at it and find the problem.
spacer
Posted by jewboy419 on October 10th 2004 (15:34)
pressanykey.gif i am doing a php on euoropean lycos and i get an error when using this code: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near" the first line of the code... can' anyone help!!!
spacer
Posted by sintekk on October 10th 2004 (11:18)
QUOTE (Red Squirrel @ Jul 6 2004, 08:41 PM)
Tripod actually has php amd mysql? That's cool, I did not know that.

Only the European lycos, the US one still believes that everybody that wants a website with them just wants to make a Hillary Duff fan page laugh.gif

...now only if there was a free ColdFusion host out there sad.gif...

spacer
View all comments
Post comment


Top Articles Latest Articles
- What are .bin files for? (669062 reads)
- Text searching in linux with grep (161180 reads)
- Big Brother and Ndisuio.sys (150471 reads)
- PSP User's Guide (139547 reads)
- SPFDisk (Special Fdisk) Partition Manager (117240 reads)
- How to Use MDADM Linux Raid (188 reads)
- What is Cloud Computing? (1225 reads)
- Dynamic Forum Signatures (version 2) (8769 reads)
- Successfully Hacking your iPhone or iTouch (18714 reads)
- Ultima Online Newbie Guide (35906 reads)
corner image

This site best viewed in a W3C standard browser at 800*600 or higher
Site design by Red Squirrel | Contact
© Copyright 2017 Ryan Auclair/IceTeks, All rights reserved