Archive for the ‘Beginners PHP Articles’ Category

Android and iOS Development – the easy way!

Tuesday, February 15th, 2011

Hi,

I’ve been getting a lot of emails lately that are kinda like this:

Stef, I want to learn how to create apps for iPhones, iPads and Android devices … can you teach me!

Well the good news is that I am looking into this now. The bad news is that I don’t have anything ready … yet. That said, I do have some useful information and strategies for people who want to jump on this bandwagon quickly and easily.

Listen up …

iOS is for iPhones and iPads

That means you need to learn objective C … if you want to have total control over the iOS device. More on that later.

Google’s Android – on phones and tablets.

That means you need to learn a subset of Java (basically stripped down Java) if you want to have total control of the devices.

About objective C and Java

I don’t know much about objective C (but I’ve heard things …) but I do know a lot about Java. In both cases, many junior level PHP programmers might have a hard time with these languages because they require a deeper understanding of OOP.

The solution: HTML 5 and CSS3

The great thing about mobile applications, is that we expect that most of the time, they will be connected to the Internet – we assume that the apps will interact online at some point if not all the time.

This opens up the possibility of moving some of the heavy lifting over to the server where PHP can take care of biz for you. This MAY minimize the need to have to go down to the core of the device, forcing you to use Java or Objective C … depending on the device of course.

In the meantime, you can use HTML 5’s nifty new ability for local storage (of files,) to handle the times when a smart-phone is NOT online. How often does that happen …?

Stefan Mischook
killerphp.com

Password Protecting Pages with PHP

Saturday, January 29th, 2011

password protect pages with php

Hi,

I recently got an email asking how to create password protected pages .. in an easy fast way for a beginner to PHP. From the email:

I was wondering if there is some premade script and setup for database I can utilize to get this up faster and still proceed to educate myself.

As any experience PHP nerd knows, there are several approaches one could take. But since this guy is new to PHP and programming, I decided on something simple:

(more…)

Killersites Community Blog – Basic PHP System: View, Edit, Add, Delete records with MySQLi

Monday, December 6th, 2010

Forum
Hey Everyone,

Here’s some helpful info on a basic PHP system, from our Killersites Community Forum!

Basic PHP System: View, Edit, Add, Delete records with MySQLi

This is a revised version of my previous tutorial (http://www.killersit…eteadd-records/) which uses MySQLi rather than regular MySQL to connect to the database. MySQLi, often called MySQL Improved, has several advantages over regular MySQL, including support for prepared statements (which helps prevent SQL injection, a common security issue) and object-oriented code. I’ve also provided a modified view.php file that shows one way to do basic pagination.

I have also recorded a 8 part video tutorial (a bit over an an hour worth of video) showing how to build this system and explaining it as I go. It’s available in the KillerSites University (http://www.killersites.com/university – subscription required) under PHP > PHP CRUD Videos.

(Anyone with PHP knowledge is welcome to comment on the code. If there are issues I haven’t noticed, please let me know. Do realize that it is intended for beginners, so I didn’t want to do anything too advanced that might lead to confusion. Yes, I realize I could use OOP, or could separate some of these out into methods, etc. etc.)

OK… Here’s some code for you to play with. It’s a basic system that allows you to:
– view existing records
– edit existing records
– delete existing records
– add new records

Online demo:

http://www.falkencre…mysqli/view.php

Basically, just imagine that you are in charge of a sports team, and you want to keep a list of all your player’s contact information. The code I’ve created could be a starting point for that (it only includes fields for their first name/last name, but could obviously could be expanded to use more fields).

This is just a basic starting point for projects that require view/edit/delete functionality. I know it may seem a lot to understand at first, but read all the comments in the code — I try to explain what I am doing step by step. I’m also happy to help with any questions (please post questions in a new topic.)

How to create a system that allows a user to add/edit/remove data in a database seems to be a commonly asked topic, so I may adapt this into an actual tutorial at some point in the future.

DATABASE:
– You’ll need to create a database (I named mine ‘records’ but it can be changed) using PHPMyAdmin
– Save the included sql file on your desktop as a .txt file
– Once you’ve created the database, make sure the database is selected, then click the “import” tab
– Select the .txt file on your desktop, and import it into your database. PHPMyAdmin will create all of the necessary tables/import some test data for you to play with

Written by: Ben

For the test data and the rest of the post, click here!

Thanks,

Jody
Killersites.com

Learning Java OOP gently …. through PHP!

Thursday, November 18th, 2010

Hi,

Some of you may know that I am an old Java programmer … big into POJO’s and I loved servlet filters. Those days are long gone now (for a whole host of reasons) but I still clearly remember how hard it was for me to learn Java. It could have been much easier though!

Learning OOP Java easily through PHP

If you already know OOP from another language, then by all means, jump right into Java … you should have know problems. If on the other hand you are like I was, where you don’t understand OOP yet or you haven’t even programmed before, do yourself a big favor and learn the principles of OOP (object oriented programming) with a much easier to understand language like PHP.

… Yes, PHP doesn’t look a lot like Java but the OOP constructs and principles are the same. Except with PHP, it is much less complicated. I won’t get into the specifics why, but let’s just say Java makes you do a lot more work to get the same things done as compared to PHP.

When Learning to fight, better to start with an easier opponent.

Besides getting my nose broken 3 times, boxing taught me that when you are first learning to fight, it’s a good idea to not get into the ring with Mike Tyson. Otherwise you will probably get knocked out and you might even get your ears bitten off.

The same is true for learning object oriented programming; better to learn this style of programming with an easier to understand (and use) language like PHP, instead of Java – the Mike Tyson of languages.

Where to learn OOP programming?

So if you think what I say makes sense, then head over to my very popular, super easy to understand FREE lessons on PHP and OOP.

… I’m sure many Java wannabe’s will find the lessons useful.

See you on Live!

Stefan Mischook
www.killerphp.com

Complete Web Programmer vs. Complete PHP Programmer?

Monday, November 15th, 2010

I got an interesting email question today:

As ever I am always planning ahead. Since I am now half way through your Complete Web Designer course I am looking to complete the Complete Web Programmer next.

But I have noticed the Complete PHP Programmer also. Looking at the modules these seem quite alike. Has one replaced the other? Which one is better suited to the beginner (me) and why?

Hi Mick,

The Complete PHP Programmer has the same content as the Complete Web Programmer minus the Javascript and JQuery material.

We added that course because some people only want to learn PHP. I recommend the Complete Web Programmer if you want to become a web programmer though, since Javascript is so central these days to dynamic websites.

Mick continues …

Im still thinking of purchasing your HTML5/CSS3 DVD first and getting the best grasp of HTML/CSS before branching out, but I like to plan ahead also. I aim to get through all of your courses that are relevant to myself at one point and as such trying to work out a rough order.

The order of learning things, is ultimately a personal thing. That said, I generally believe that learning the basics of the big four is first priority:

1. HTML
2. CSS
3. PHP
4. Javascript

… I would then move on to HTML 5 and CSS 3 simply because they are still niche technologies … growing, but still niche.

Stefan Mischook
killerphp.com

PHP Programming: 1 part code, 2 parts testing.

Sunday, November 14th, 2010

Any programmer with more than 3.2 days of experience knows that programming has a lot more to do with testing than coding.

Most errors in software are human related – typos, failed attempts at logical-construct construction etc …. This knowledge make two things clear:

1. Using proven frameworks or libraries (like Zend, CodeIgniter, PHPCake etc) will save you a lot of time and you will end up with more robust applications since the framework’s codebase will be cleaner than a from scratch solution you create.

2. Testing should be significant part of the regime – test and retest, I like to say. I would even suggest a testing protocol be put in place (unit testing on the object level can make sense) where with each update to the codebase, a series of related test of the application is initiated.

How Simple Errors Can Cause Big Problems

We’ve recently been updating the shopping cart system on killervideostore.com and I found errors creeping into the application that prevented some buyers from actually buying product … this is a problem for a store!

:(

The funny thing is, that the problem was a simple UI bug (simple CSS fix for IE) that pushed buttons out of view and so the buying process was made impossible. A simple retest of the UI on all the major browser before publishing would have been a good idea IMHO.

… That’s the funny thing about bugs, they show up where YOU DON’T EXPECT THEM.

Stefan

Perl Programming in the Modern Web?

Monday, November 8th, 2010

Hi,

It has been a while since I’ve written an article on killerPHP … and so it’s time for another one of my inflammatory articles!

Before I begin, I should point out that I’ve written articles so vexing to other geeks out there, that it caused them to quit other sites and flame wars so brutal developed, that threads had to be closed and apologies issued.

Fortunately, this little article on Perl’s place in the modern Web will only mildly annoy a few old-school Perl nerds. Yes, click on the link just above to read it … I don’t want to post it twice.

Thanks,

Stefan Mischook.
killerphp.com

Three good PHP IDE’s … that’s ‘nerd’ for PHP Programs

Monday, September 20th, 2010

Hi,

So you want to write PHP code but you are not sure what program to use? Well, there are many options out there for PHP nerds (which is good) but again, which one to use?

Many times, this comes down to personal taste and I don’t know all the options out there … so I will limit it to three:

http://netbeans.org/features/php/

From the Netbeans site:

The NetBeans project offers a version of the IDE tailor-made for developing PHP web sites that comprise a variety of scripting and mark-up languages. The PHP editor is dynamically integrated with HTML, JavaScript and CSS editing features.

Focus on the code and speed up code scanning by excluding individual directories in the Project properties. The NetBeans IDE fully supports iterative development, so testing PHP projects follows the classic patterns familiar to web developers.

http://www.eclipse.org/downloads/

http://www.adobe.com/products/dreamweaver/

I encourage you to try all three options and see what you prefer. Netbeans and Eclipse are more for programmers and have very powerful tool sets in that regard (that means they have all the bells & whistles) but for web designers getting into PHP, Dreamweaver maybe the choice.

… OK, Dreamweaver is not the best at PHP and I would probably not recommend it for hardcore PHP application development. But if you are building small to medium sized PHP applications, then it can more that handle the job with its’ basic code hinting, macros etc.

Stefan

My Killer PHP Learning Tips

Thursday, September 3rd, 2009

php logo

Hi,

Learning to program can be a frustrating process for a lot of people; especially for designer types wanting to learn a little PHP. The following tips should help a lot of you along the way to becoming a PHP nerd. My PHP learning tips:

1. Be patient:

Patience is a virtue, especially when learning to program. Don’t be discouraged if something doesn’t sink in right away. It will come with time.

2. Learn to write code on faith:

… That means writing PHP code that you may not fully understand. The process of actually writing out the code, seems to help the brain take it in.

3. Learning PHP programming is a lot like learning a sport; you can pick up stuff by sitting on the sidelines and watching, but you don’t really know what you’re doing until you actually get into the game. In PHP, that means actually writing code and not just sitting listening or reading about it.

4. Take a breather:

If something is not sinking in right away, move on to something else and come back to it later … actually, give it 24 hrs to sink in. I find that the brain will work on problems over night and almost magically, things that you could not understand the day before, will become obvious.

5. Try variations in your code:

Play with different ways of doing things, try to add variation to your code. If for instance you are learning something as simple as a conditional statement .. like the ‘if’ statement, try some examples with mathematical equations and then maybe try something using a function that returns a true/false value.

6. Break your code:

One of the best ways to learn any programming language is to purposefully break code. Why? Basically it comes down to seeing what type of error messages you get for certain types of mistakes in your code. In time, you will see that particular errors will give you consistent error messages. Once you know these, debugging code will be a lot easier.

I’ve found that breaking things on purpose and in a controlled manner, can really help down the road when you run into real errors, because you will recognize the error messages.

PHP vs. Perl vs. Java – a student’s question.

Monday, August 17th, 2009

Once and a while, I get a question from a student about PHP and programming that I use in a blog post … here we go again:

… you mentioned that you used to use mostly Java but have switched to mostly PHP. Would you recommend learning PHP as a primary method of creating dynamic web pages or is its strength in data base manipulation. I was learning Perl form processing which led me to your site when I was having trouble with mySQL, and I noticed PHP is very similar (at least in the basics) as Perl. Do you have much experience in using Perl to help create web pages and would you recommend using it at all?

About PHP vs. PERL vs. Java:

PHP is the way to go. Perl is a good language but it was not designed initially for web development – that functionality was added later.

Whereas PHP (which borrows from Perl btw) was designed specifically for web development, and so Perl is just clunkier compared to PHP when it comes to creating dynamic web sites.

I’ve used Perl in the past, mostly creating simple string parsing scripts and other little things. But I would NOT call myself an Perl programmer – so take that into consideration.

That said, I’ve always liked a common strategy used in Perl, where they generate static pages from dynamic code. For example, in our web designers directory, I used a Perl based directory script that uses that strategy.

… What’s interesting is that it generates the directory pages as static HTML pages. The advantage of this is that the directory itself is more portable and much less resource intensive because for the most part, the directory is just of pages that people just read … no need for them to be dynamically generated every time a user request it.

(more…)

Server Migration is Easy with PHP

Monday, July 13th, 2009

Recently we had to make an emergency move from our old servers (where we had been for 5-6 years) to our own dedicated server because of technical difficulties in the heads of the nerd’s who managed the servers killersites.com had been sitting on.

I will spare you the details of my server migration ordeal for now. What I want to point out, is that PHP (once again) has proven to be a great choice as the server side programming language.

PHP is consistent …

During this move, I had to deal with a bunch of web apps and scripts that included a nice buffet of technologies like:

- Perl
- PHP
- Java

.. Yes, the dreaded evil configuration hell that is J2EE!!

To make a long story short, migrating the PHP apps was a snap – copy over the files, set up the database and were off! On the other hand, I still have to get around to figuring out why the Perl and Java applications don’t want to run on the new server.

:(

PHP continues to rock, saving me time, money and headaches.

Stefan Mischook
www.killerphp.com

Programmers should learn to be language agnostic.

Monday, July 13th, 2009

In my last post I wrote about how Ruby’s early problems around 2006-2007:

- incomplete libraries
- difficult web server integration

.. had played a role slowing its adoption. The main thrust of the piece was to point out that despite the explosion of interest, Ruby and Rails had failed to make much of a dent relative to PHP in terms of usage. In fact, PHP is still far and away a much more popular language.

(more…)

PHP Video: always MySQL with PHP?

Wednesday, June 3rd, 2009

php video

Hi,

In this HD video (running time: 4:06), I answer a question put to me recently:

Should you always use MySQL as your database when working with PHP?

Yes, this is a beginners question, I know. Nonetheless, it is a legitimate question that I think is worthy of comment. In answering this question though, I briefly talk about the other database options you have with PHP.

The video:

MySQL with PHP

Note: I am using Youtube’s new HD streaming capabilities as an experiment. This is 720p video so you should have a fast connection to watch it, or some patience. If you find the video is stuttering, just press ‘play’, then pause it and then give it a minute or two to download.

Thanks,

Stefan Mischook

How to Build a Content Management System

Sunday, October 5th, 2008

OK, I just tricked you! This article is not going to teach you how to build a content management system with PHP from scratch.

Why not?

… Because building a content management system from scratch is (probably) a really dumb idea!! Now that I come to think about it, building any of the most commonly used software from scratch, is kinda stupid.

Things you should not build from scratch:

  • Content Management Systems
  • Blog Software
  • Forums
  • Directory scripts

The Top 3 Rules in Programming

The real estate business has a famous set of rules – the top three rules in fact:

  1. Location
  2. Location
  3. Location

The idea behind this rule, is to stress how important location is to a piece of property. In software development (programming), we have a similar set of key rules:

  1. Reuse
  2. Reuse
  3. Reuse

(more…)

SQL insert statements in PHP

Saturday, July 19th, 2008

Hi,

I’ve finally released my first video on using SQL statements in PHP pages. This is the next step after connecting to a MySQL database.

I hope you find the videos useful.

Stefan Mischook
www.killerphp.com

How to call functions from another class.

Saturday, July 19th, 2008

Many of my articles and videos are based on questions that I see popping up in the php forums or in emails sent to me personally.

Recently I was asked by someone how they could call a function found in one class, in another. This may seem like basic stuff to those of us who know … but please keep in mind, at one time, none of us knew anything!

:)

Anyway, here is my video on using a function from another class in a class.

Why build all your web pages in PHP?

Thursday, May 15th, 2008

I recently had this question put to me by a web designer who was considering the idea of using PHP pages in her websites:

“Why build all your pages in PHP … Why not use standard .html pages?”

She then expanded the question to:

“What I mean is…… what’s the benefit to building ALL sites in PHP?”

Note to uber-nerds: remember that this question is being put to me by a web designer who has never written software. As such the answer is tailored those who are new to programming.

I might tackle this question from another perspective if the question was put to me by an experienced developer.

PS: If you find my answer offensive to your nerd-sensibilities, you might want to read this.

The Answer:

By making all your web pages PHP pages from the start, you are basically leaving open the possibility of using PHP in your web pages at any time.

… You don’t want to (at some later date) have to go back and change your .html pages to .php. For example:

  1. my-product-list.html
  2.  
  3. … becomes:
  4.  
  5. my-product-list.php

Beginners should note, that you need to have .php extension on any web pages where you want to use PHP. Check out my basic PHP videos for details.

-

PHP can do a lot more than just talk to MySQL. One very common use of PHP is to create ‘includes’ … this will allow you to insert snippets of code in your pages from separate files. This is kinda like using external CSS files. So you can use PHP includes to say create your page footers.

You can learn more about PHP includes in my free videos.

In the end, by making all your pages php pages from the start, you will just have a more flexible website to work with since you will be able to access PHP’s power.

Stefan Mischook

www.killersites.com

NEW BASIC SQL TUTORIALS

Tuesday, April 1st, 2008

Hi,

I’ve managed to upload new video tutorials on SQL basics. At this point, I’ve covered the four big SQL statments:

  1. INSERT
  2. SELECT
  3. UPDATE
  4. DELETE

You can view the videos here: Basic SQL Statements Video Tutorials.

Now that we have that covered, my next videos will be on using PHP to connect to and work with MySQL.

Thanks,

Stefan Mischook

www.killerphp.com

BASIC SQL TUTORIAL

Monday, March 31st, 2008

Hi,

mysql-logo

I’ve just put up a new sub-section on SQL – the language of relational databases.

This is beginners stuff, so if you’re a know-it-all nerd, you can ignore this. On the otherhand, if you’re new to the database thing (mySQL for example) then these first couple of videos should help you get started.

Videos out so far:

- Introduction to SQL
- Introduction to the SQL ‘insert’ statement.

I plan on having a bunch of new videos out soon that cover:

  • The big four SQL statements.
  • The basics of database design.
  • The cardinal rules of database design.

My goal is to not turn you guys into database gurus, rather, I want to just give you enough so we can get you going with PHP and mySQL.

Thanks,

Stefan Mischook

www.killerphp.com

PHP Video Tutorials for iPods

Wednesday, February 20th, 2008

ipod-php-video-icon

Because of recent demand, I decided to release my PHP video tutorials in iPod format – that means they play on your iPod.

:)

… OK, you guys guessed that one.

These video were originally intended for viewing on a computer monitor, so some of the code examples will be harder to read since iPod screens are smaller.

Nonetheless, the discussions may be useful to watch on your iPod as you’re … say, on your way to work or school.

A small note: I’ve added some brief comments (in text) about each video, to give you a better idea of what you will find in the video before downloading it.

You can find the videos on the new iPod video page.

Thanks,

Stefan Mischook

Top of page  go to top of page