PHP

The section to come to for beginning PHP tutorials, tricks and other serverside nonsense. PHP is a fairly accessible scripting language that will seem really familiar to C programmers or to anyone who can program or script in a C-like language. PHP is becoming more and more popular especially with the arrival of PHP 5 and PHP as an object oriented programming language.

PHP Basic Loops and Conditional Structures

Basic PHP Control Structures This article continues from PHP Vari­ables Primer. At this point we will add something that will actually allow you to use what you know to make simple, useful PHP scripts. I'm going to call them control structures. There are quite a few handy control structurs in PHP but we will only cover the FOR loop and IF along with ELSEIF and ELSE as this tutorial is supposed to be just the basics. Check out the PHP code below... for ($variable=0; $variable<10;...

PHP Variables Primer

This article continues from PHP 101-Learn the Very Basics of PHP. What in the world is a variable?! Think algebra. The wacky x + 5 = 15 stuff. In PHP it would be something like echo $x + 5;. "$x" would be the variable. If "$x" is nothing then PHP would echo 5. If "$x" were ten then PHP would echo 15. A variable is just a named chunk of memory for you to store information in. Assigning a variable is fairly simple. You could easily use something like var $x=5; or even simply $x=5; wou...

PHP Quotation Marks in String

There are a couple of different ways to include quotation marks within a string in PHP without causing errors. The below code demonstrates them and then I will explain each. ; Escaping Special Characters With Backslash The above code will output 3 lines each containing "hello". The first example uses PHP's escape character to escape the quotation marks inside the string. This tells PHP that you meant the quotation marks literally. You really want them there and didn't mean them for P...

PHP 101-Learn the Very Basics of PHP

The Big Prologue The whole purpose of this little tutorial is simply to get you started with PHP. I am assuming a lot of things. For one, I assume you are familiar with building web pages in HTML and using some kind of FTP client. These things are pretty much necessary if you want to tackle a serverside scripting language. If you do know HTML and can wield an FTP editor and even notepad you will do alright. PHP basics really are not that incredibly hard to pick up. As with just about...

Problems with mysql_real_escape_string()?

Mysql_real_escape_string() Syntax First let's take a quick look at how the manual says that mysql_real_escape_string() is supposed to be used. Check out the prototype below and notice the "resource link_identified" that is given as the second argument. mysql_real_escape_string    ( string [, resource link_identifier] ) This resource link_indentifier is actually the id that is returned from a call to mysql_connect(). What this means is that, for whatever reason, mysql_real_escape_string() act...

Cannot Modify Header Information Error

What's a Header and What's Wrong With It? No this isn't a soccer tutorial. We are talking about a common error in PHP scripts. The header we are talking about is a piece of data that precedes a larger chunk and carries information about how to handle the larger chunk of data. Note that this "header information" must precede the actual data. An example would be the header of any file on your computer. There is a chunk of data attached to the top of almost every file that tells your op...

Quick and Easy RSS Feed Reader

Quick and Easy RSS Feed Reader RSS feeds can really be quite handy in keeping your users up to date with what's going on in the world. Many large sites with RSS feeds offer javascript code that allows users to display a list of current content on their website. This makes it easy for people with little knowlede of XML and server side scripting. Some add RSS content to their sites for users while others for search engines. In either case javascript can fall short of perfect. Users withou...

Manage Content With PHP Includes

PHP Includes Basics Have you ever had to makes changes on a site that uses no includes and no external CSS file? What about a site with several thousand pages? Do you fully understand what this can do to a developers mental sanity? If not then you probably really don't want to know. It's not pretty. There is a way to alleviate this drive for mental breakdown though. Server side includes allow you to reuse pieces of your web pages by putting the pieces in seperate files and then includin...