| 0 comments ]

Append a String to a File Using PHP

To append a string to a file you will need to open the file using fopen() with the 'a' parameter. For example...

Determine a File Extension Using PHP

There are several ways determine a file extension using PHP. First is using the combination of strrpos() and substr...

PHP Number Formats

PHP's solution to formatting number is the number_format() function. This function take 4 arguments but only...

Reading a File Using PHP

A simple method for reading a file is to use the file() function which will return an array containing each line...

List a Directory's Contents Using PHP

To list the content of a directory you just need to use the combination of opendir() and readdir() functions. ...

Executing a Shell Command Using PHP

You can use either system() or exec() . Just remember to ALWAYS use the full path to the command. So instead of...

Finding Sub-Strings using PHP

PHP already have the function that check if a substring exists in another string. It's called strpos() . This...

Remove a File Extention Using PHP

To strip the file extension from a file name you can use the combination of strrpos() and substr() function like...

Remove a File Using PHP

To remove a file from php use the unlink() function. You can enter either the full path or the relative path to...

Read HTML files using PHP

Reading an html file is just like reading any other file. You could use fopen() combined with fread() or file_get_contents...

Reading a Remote File Using PHP

To read a remote file from php you have at least four options : 1. Use fopen() 2. Use file_get_contents() 3. CURL...

Image Gallery : Album List

Here is the page that the gallery visitors see. The code behind it is mostly the same as the one in the admin pages...

Image Gallery : Image List & Detail

Clicking on one of the album icon from the album list page will bring you to this page. The layout is similar to...

Image Gallery Administration Page

Login and logout Before you can access the admin pages you will need to login first. The login method is very basic...

Admin Page For Content Management System (CMS)

Now we start creating the administration page for our content management system. This page will list all the articles...

Creating A Guestbook Using PHP and MySQL ( Part 2 )

Welcome to the second part of this guestbook tutorial. In case you haven't read the first section then go here...

PHP and MySQL Resources on the Net

PHP MySQL Resources PHP Homepage Of course, I have to list this site here. This is where you can to download the...

User Authentication in PHP

Here are some authentication method that we'll discuss Basic authentication We hard code the username and password...

Uploading Files To the Server Using PHP

Now, we will make another upload script. But this time we won't save the file in the database. We will only...

Finding PHP and MySQL Hosting

There are a lot of things to consider when choosing a web hosting company. But one thing for sure is that price...

Paging Using PHP and MySQL (Part II)

When there's more than one column involved in paging there isn't much that we need to modify. We only need...

Update and Delete in MySQL

Delete Data The DELETE statement deletes rows from a table that satisfy the condition given by the WHERE clause...

Retrieve Data from MySQL Table

Retrieving the table data is easy, just use the SELECT statement like this mysql> SELECT * FROM species; +-...

Add Data to a MySQL Database

You can insert data to the tables directly from mysql> prompt or by loading a file containing the data. The...

Create a Table in MySQL

For this example we'll create two tables. The first one describe the species of animals available in a pet...

Create New MySQL Database

You need to use mysqladmin to create MySQL database. The command is simple just write mysqladmin in a dos window...

Add New MySQL User

For adding a new user to MySQL you just need to add a new entry to user table in database mysql . Below is an example...

Starting MySQL

Before starting the MySQL client make sure the server is turned on. If you run Windows 9x start the mysqld.exe...

PHP Editors

Because PHP files are just plain text files you can use any editor to create and edit PHP files. But even though...

PHP Forms

Using forms in a web based application is very common. Most forms are used to gather information like in a signup...

PHP Functions

Real world applications are usually much larger than the examples above. In has been proven that the best way to...

PHP Control Structures

The next examples will show you how to use control structures in PHP. I won't go through all just the ones...

Strings in PHP

Strings are probably what you will use most in your PHP script. From concatenating, looking for patterns, trim...

PHP Variable Types

PHP supports eight primitive types. Four scalar types: boolean : expresses truth value, TRUE or FALSE. Any non...

PHP Variables

Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case...

Using PHP Comments

Comment is a part of your PHP code that will not be translated by the PHP engine. You can use it to write documentation...

Opening & Closing PHP Tags

To open a block of PHP code in a page you can use one of these four sets of opening and closing tags Opening Tag...

Image Gallery : Modify & Delete Images

Here is the snapshot of the modify image form. It's very similar to the form to add the image except for the...

Image Gallery : Add Image

Adding a new image is easy. Just select in which album you want the image stored, supply the image name, description...

Image Gallery : Modify & Delete Albums

Here is the page where you can modify an album's name, description and image icon We display the album thumbnail...

Image Gallery : Add New Album

This is a very simple form where you can enter the album name, description and image. After you click the "Add...

User Authentication : Storing User ID's and Passwords In a MySQL Database

A more common method of authenticating a user is by checking the database to see if the submitted user id and password...

Basic User Authentication

With this basic authentication method we store the user information ( user id and password ) directly in the script...

User Authentication with Image Verification

In some cases you may want your loging form to be able to prevent automatic login by a robot ( script ). To achieve...

Content Management System ( CMS ) using PHP and MySQL

A Content Management System ( CMS ) is used to add, edit, and delete content on a website. For a small website...

Uploading Files To MySQL Database

Using PHP to upload files into MySQL database sometimes needed by some web application. For instance for storing...

Creating A Guestbook Using PHP and MySQL

You've seen it at least once right? Guestbook is one of the most common thing to find in a website. In this...

Form Validation Using PHP

Whenever you make a form you should not leave it alone without any form validation. Why? Because there is no guarantee...

Using PHP to Backup MySQL Databases

There are at least three ways to backup your MySQL Database : Execute a database backup query from PHP file. Run...

MySQL Update and Delete

There are no special ways in PHP to perform update and delete on MySQL database. You still use mysql_query() to...


Paging Using PHP

Ever use a Search Engine? I'm sure you have, lots of time. When Search Engines found thousands of results for...

Retrieve Data From a MySQL Database

Using PHP you can run a MySQL SELECT query to fetch the data out of the database. You have several options in fetching...

Insert Data into a MySQL Database

Inserting data to MySQL is done by using mysql_query() to execute INSERT query. Note that the query string should...

Create a MySQL Database With PHP

To create a database use the mysql_query() function to execute an SQL query like this
In MySQL Tutorials written by admin on 12-18-2008

Connect to MySQL Database

Opening a connection to MySQL database from PHP is easy. Just use the mysql_connect() function like this

Getting Started with MySQL

MySQL Tutorial - Getting Started By : PHP-MySQL-Admin Nov 11, 2005 This mysql tutorial covers the basic stuff that...

Getting Started with PHP

What is PHP? PHP is a web programming language used to write dynamic webpages. In this tutorial you will learn...

Installing PHP and MySQL

PHP and MySQL are usually associated with LAMP (Linux, Apache, MySQL, PHP). However, most PHP developer ( including...

Source:
http://www.php-mysql-tutorial.com/wikis

| 0 comments ]

With the flurry of press coverage on PHP recently, I'm often asked, "Will learning PHP enhance my career?" My answer depends on where you are in your career. What makes you valuable today? Let's say you're a business developer with RPG/Cobol skills. Your salary is probably around $80,000 per year (depending on geography), and you have more than 20 years of experience writing business applications that work. So let's say you dedicate two to six months of your free time to learning PHP, and then you go on an interview. I can guarantee you that they'll ask you what applications you've written in PHP. What they really want to know is how your web applications gave a company a competitive advantage. But you don't have that experience. You just wrote toy PHP applications so you could learn syntax. The interviewer will then compare your PHP skills with those of other applicants. Understand that many of these other applicants are half your age, and they'd be happy with $50,000 or $60,000 per year. Many of them will have a couple of years of solid PHP experience. In that scenario, the answer to your question is, "No. PHP won't enhance your career." So don't put yourself in a situation in which you'll be compared with a twentysomething based only on your knowledge of PHP syntax.

Now, let's put that twentysomething's career in perspective. Has he or she written real-world business applications for inventory, accounting, or sales analysis — applications that contain complex business rules and interactions with other systems? Probably not. They might have created an online sales application that writes to a simple MySQL database. Let me be clear: It's more important to be able to leverage the wealth of web technologies and web development tools than it is to be a PHP wizard. Here's a short list of web tools and technologies: HTTP, HTML, CSS, XML, SMTP, web services, SOAP, REST, JSON, SQL, JavaScript, SSL, encryption, regular expressions, CVS or Subversion, editors, debuggers, IDEs, HTTP servers, and application servers. If you can clearly define how these technologies can be used to make a company gain a competitive advantage, especially with your business experience, you'll have a distinct advantage over a twentysomething PHP hacker. So that's the "yes" answer to your question. PHP is a highly approachable web language that lets you paste together Internet technologies to construct a business application. PHP has great facilities for most web technologies, but you need to truly understand a web technology to be able to effectively use it in a PHP application.

To develop web applications, you need to be able to transfer your core skills at developing business applications to web development. You'll need to write applications in languages other than RPG (or alongside RPG), use SQL as the data-definition and data-manipulation language, and make the applications deployable to a variety of platforms. Does this sound familiar? In addition to learning PHP, you'll need to learn the web tools and technologies that I listed earlier. So how do you get skilled in these technologies? First, study each in a nutshell. Second, get real-world experience in that technology.

Studying a technology in a nutshell requires you to rip it apart and look inside. Immerse yourself in that technology. When your friend Dave sees you and says, "Hey, Bob, what's up?" Instead of saying, "Nothing much," answer, "CSS." Another time you might answer, "web services." You need to examine each web technology until you understand how to leverage it in a business application. The time required to get to that level of understanding depends on the technology. HTTP and SMTP might take you one week. HTML and CSS might take a couple of weeks. Web services, SOAP, and REST could take several months. You probably will be side tracked with tooling setup for things such as IDEs and HTTP servers. But don't just shuffle through getting those tools working; make a study of it — as if you'd be in charge of installing, configuring, and training others on that tool.

Many people feel that getting real-world experience on a technology is difficult. Balderdash! Are you telling me that your church, your sports organization, or your company has no need for a web application that uses at least a few of these technologies? And even if none of your organizations needs a website or you're reluctant to volunteer your time (even though it will enhance your career), you can try putting your own application on the web as a mini-startup. It costs as little as five bucks a month to have a PHP or Java application run on a hosted server. It may not make you millions, but it could boost your career. It's also pretty cool to put your website on a résumé.

It's a little naïve to think that simply learning PHP will enhance your career. But being able to leverage your core business application development competency to create applications that take advantage of the wealth of web technologies is smart, real smart.

Don Denoncourt is a System iNEWS technical editor.

| 0 comments ]

Anyone who has designed web sites for any length of time knows the limitations of html and other client side languages like CSS and JavaScript. While these languages remain at the core of web development, their primary function is to control how text and graphics are presented. Because they lack the ability to manipulate information on demand, or communicate with web servers, the result is a static web page.

The ability to create dynamic pages opens doors. Suppose you wanted to create a survey to collect information from visitors to your web site. You could easily create a form with HTML that included all your questions, and have the results emailed to you. But to convert the raw information into a meaningful format, you'd have to manually compile it, and then organize it to gauge the results - a process which could take hours.

Fortunately for you, using scripting, there are easier ways to collect and evaluate the results of the survey, or any form. Rather than sending the information through email, a script grabs it and stores it in a database on the server. A second script communicates with the database, gathers and groups the information, and prints it out when you visit the page. The script could also produce bar graphs, percentages and totals, or present the information any other way you could conceive; automatically, and on demand.

So what language do you use when you want to analyze survey results? Or offer personalized information to your visitors, or display an archive of journal entries without managing copious HTML files?

In recent years, more and more developers have been turning to a relative new-comer to the scripting world for the answer: PHP.

What is PHP?

PHP, which stands for PHP Hypertext Preprocessor, is a server-side embedded scripting language. In non-technical terms: a PHP processor is run on the server (Windows, or a flavor of UNIX). When a page is requested that contains PHP, the processor translates and executes all the commands in the page, and then outputs the result to the browser as regular HTML. Because this translation occurs on the server, a page written with PHP is viewable with any browser, on any operation system.

Like most other scripting languages, PHP can be embedded directly into HTML. PHP code is separated from HTML by Start and End entities. When a document is parsed, the PHP processor only interprets the demarked areas, and outputs the results in the same position.

Ironically, PHP also includes the ability to almost completely separate code from HTML. For larger, collaborative projects this method is ideal because it allows designers to work on the layout of the page without interfering with the code aspects.

A Little History

PHP was introduced in 1994 as a loose collection of freeware scripts based on Perl and dubbed "Personal Home Page" Tools. The author, Rasmus Lerdorf, received surprising interest in the package from the professional and developer communities. By 1995, a mailing list had been established where other developers could provide feedback, bug-fixes and code ideas on the scripts.

Encouraged to expand the original package with additional features, Lerdorf released PHP-FI (or PHP2) in 1995. This version included the ability take the information submitted by forms on the web and convert it to usable variables. What was so important about this function was that it enabled user input to be captured and acted upon, allowing more complex and interactive web applications to be developed.

It was around this time that PHP changed from being a one-man project to one with a group of 7 core developers. Together, they refined the syntax of the language, added additional functions and methods, and the ability for other programmers to extend the capabilities of the language by plugging in modules.

With the release of version 3 in 1998, PHP had finally grown into its own. Like C and Perl, PHP is a structured programming language with variables, functions and classes. Its similarity to these languages encouraged experienced programmers to migrate to PHP and its ease of use rapidly won new users.

By version 3, PHP also included database support for a wide variety of platforms including mysql, mSQL, ODBC, Oracle and Sybase. It also was able to work with images, files, FTP, XML, and a host of other technologies.

The latest release of PHP is version 4. Rebuilt with a more powerful core processor, the new PHP engine (the Zend parsing engine) offers significant speed improvements over previous versions. PHP4 also includes sessions support (an easier way of working with cookies), and numerous smaller additions and improvements.

To date, PHP is still free and a frontrunner in the open source movement. However, unlike many open source projects, it's becoming more and more mainstream as an increasing number of businesses and organizations are making the switch to it.

For professional developers, one of the most exciting things has been the release of the Zend Encoder, which allows PHP source code to be encrypted. The Encoder carries a hefty price tag, but it holds the promise of more built in value for those selling custom scripts.

Why PHP?

It's no secret that there are alternatives to PHP: ASP, Cold Fusion, and Perl, to name just a few. While each of these languages has differences in syntax and structure, when it comes down to it, they can all produce the same results.

So, why would you choose PHP over other options?

- Simplicity. For people new to programming, this is frequently the strongest appeal. Even those with little or no programming experience can quickly get up to speed and begin creating full-fledged applications. Because it was specifically designed for creating web applications, PHP has a host of built-in functions to handle common needs.

- PHP is Open Source. Because PHP's source code is freely available, a community of developers is always working to improve, add to, and find bugs in the language. Open Source means you never need to rely on the manufacturer to release the next version if something doesn't work or pay for expensive upgrades.

- Stability, and compatibility. Currently, PHP runs stable on a range of operating systems including most flavors of UNIX, Windows and Macs and integrates well with most popular servers including IIS and apache.

PHP is also endowed with other goodies, like native support for many popular databases, an extensible architecture, and a processor that not only uses fewer resources on the server than many of its competitors, but also displays pages in record time.

Finally…

This article is the first in a series, covering everything from the basics of PHP to advanced topics and including information on related subjects such as databases and XML, as they apply to PHP.

Generally, PHP is a very easy language to learn. If you have worked with another structured programming language like C, or Perl, some of PHP will seem very familiar to you, and you'll find the language very easy to pick up. But keep in mind that previous experience in programming is not a pre-requisite for learning PHP or for understanding the concepts presented in this series. The only thing that is required is a desire to make the leap to server-side programming, and a thorough understanding of HTML.

About every week or so, we'll be taking a look at a new concept or theory of the language. The emphasis will be on providing the tools needed to start programming real, usable applications as quickly as possible. Cumulative, real-world examples will provide a taste of how to structure your own scripts, as well as present solutions to situations you will often encounter in your own work.

Whether you began reading because you needed to complete a specific project, or because you were just curious, by the end of this series you can expect to know what's involved in building dynamic data-drive sites. You will also have a virtual toolbox of code snippets and script design tricks you can pull out when needed.

Most importantly, you will have the knowledge to successfully develop your own projects from start to finish.


In the next article, we'll be taking a look at how to set up a PHP development environment, including information on how to install Apache, PHP and mysql.


Liz Fulghum currently lives in Annapolis, MD where she works as a web designer for a custom shirt retailer. Liz was convinced to try PHP as an alternative to Perl; she has been a fan ever since and frequently works as a freelance developer.

By Elizabeth Fulghum