Your Ad Here
 

PHP while loop with MySQL

I have been coming across a lot of “Essential Tools For Web Developers” lists lately and I noticed that they are all really extensive.  Some of them have as many as 100 tools listed!  This begs the question, “Do you understand what ‘essential’ means?”.  So here is my EXTENSIVE list of essential tools for web developers.  This is literally every essential tool you will need to develop web applications.

Web Server Software and Extensions

First and foremost, you’re going to need a web server.  If you have a web host, disregard this tool because this is essentially the service that they provide.  If you plan to run your own web server, check out WAMP for Windows and LAMP for Linux.

Text Editor

Notepad will work.  However, I would recommend getting a better one than that since it doesn’t really have any features!  There are a ton of free options.  Some people swear by Eclipse.  I prefer Notepad++ on Windows, TextWrangler on Mac, and VIM on Linux.

FTP Client

After you have created a new script or app using your awesome text editor, you will have to upload it to the web server.  Again, there are several free FTP clients out there.  I prefer FileZilla personally.  It was originally written for Windows, but has since been ported to Mac and Linux.  The Mac version can be a tad buggy from time to time but it’s super fast still and I love it!

Ummmm…yeah…that’s it.  Nothing else is needed to develop web applications.  There are lots of helpful tools out there and they should certainly be used, but they are NOT essential!

 

What your product photo shoot SHOULD look like...

I was working on a project recently and I realized something very crucial to the world of web design.  Many people might look at this and think I’m slow for never realizing it before, but whatever.  What I realized is that no matter how amazing the layout and web design work is, the site will look bad if product photos are bad.  Up until this point I haven’t put much thought into the importance of product photos.  Most small businesses do all of their own product photography with a point and shoot digital camera with little thought about composition, color balance, background, etc.

I’m about to say something that I don’t like.  But it is the truth, and I can’t keep the truth from people.  Your website will look better if you hire a professional photographer for the product photos and spend less money on a simple web design.  Obviously, if you need a more complicated and dynamic website, you should be willing to pay for it.  I’m saying that it might not be worth it if your product photos are amateur.

The new problem is that higher quality digital SLR cameras are getting more affordable.  People buy them and suddenly they think they’re Ansel Adams.  Well, trust me, there’s a lot more to photography than the camera!  So, if you are thinking about hiring a web designer, start by taking a close look at your product photos.  If they are fairly sterile and bland looking, you might want to consider hiring a photographer instead of a web designer.  That way you can drop your new product photos into your existing website for a quick upgrade.  This will also mean that when you are ready to spring for a web designer, you will already have some professional product photos for them to work with.

 

PHP and MySQL were made for each other!

Hi Everyone!  I wanted to post a very basic tutorial series on using PHP and MySQL.  This tutorial is Part 1 and it will not focus on anything complicated, rather it will break down the process of connecting to your MySQL database.  This tutorial assumes that you know how to create a MySQL database and it also assumes that you have web hosting with PHP and MySQL installed.  For MySQL database management, I personally prefer using phpMyAdmin.  Some people prefer other MySQL clients, while some hardcores prefer doing all of their database management from within their PHP script.  I’ll leave the decision as to which method you’ll use up to you.

We will be using the following database throughout this entire tutorial series, so don’t delete it after you complete this tutorial! You’ll need it for Part 2 and so on!

Now, the first thing we need to do is create a database.  So, using whatever method you prefer, create a database called “test_data” (without the quotes) and give it one table called “test_table” with 3 fields.  The first field should be labeled “id”, and it should be set to INT, Auto-Increment, and set it as the primary key.  The second field should be labeled “name”, and it should be set to VARCHAR with a length of 32.  The third field should be labeled “city”, and it should be set to VARCHAR with a length of 64.

Okay, so now we have our database and table all set up!  So, the next thing we need to do is create our PHP script!  Open a good text editor such as Notepad++, Dreamweaver, etc.  The first thing we need to do is create a PHP code block.  Here’s how it should look:

<?php

?>

Next, we need to establish a connection to the database. We do this using the mysql_connect function that is built in to PHP. You will need to know the hostname of your MySQL server, as well as the username and password for the database. Typically, the hostname is “localhost”.

<?php
//connect to mysql database server
mysql_connect("hostname","username","password");
?>

Replace hostname with your actual hostname, username with your actual username, and password with your actual password. This code attempts to connect to your database with the credentials that you provided. The problem is, there is nothing in place to inform you if your script was successful or not! So, we will need to add some error handling.

<?php
//connect to mysql database server
mysql_connect("hostname","username","password") or die (mysql_error());
?>

Now, if you get an error, then there is something wrong with your connection script. If nothing happens at all, that means the connection is successful!

Next, we will want to make this script a little cleaner and add some code that will tell you if the connection to the database was successful or not. So we will want to create three variables at the top of our script. db_host, db_user, and db_pass. We will also create an echo for a successful database connection.

<?php
$db_host = ""; //place your hostname in this variable
$db_user = ""; //place your username in this variable
$db_pass = ""; //place password in this variable

//connect to mysql database server
mysql_connect($db_host, $db_user, $db_pass) or die (mysql_error());
echo "Successfully connected to MySQL Database!";
?>

Now that our script is connecting to our MySQL server, we just need to tell it which database we want to use. Do this using the mysql_select_db function in PHP. So, we will add one more variable at the top of our script called db_name. We will add the mysql_select_db function at the bottom of the script with an echo for a successful selection. You will notice that the success message is dynamic which will allow you to use it on other scripts without changing the code.

<?php
$db_host = ""; //place your hostname in this variable
$db_user = ""; //place your username in this variable
$db_pass = ""; //place password in this variable
$db_name = ""; //place your database name in this variable

//connect to mysql database server
mysql_connect($db_host, $db_user, $db_pass) or die (mysql_error());
echo "Successfully connected to MySQL Database!";

//Select Database
mysql_select_db($db_name) or die (mysql_error());
echo '<h2>Successfully selected ' . $db_name . ' database!</h2>';
?>

And there you have it! A perfectly respectable MySql connection script! The next tutorial will focus on the basic while loop for pulling data from the database!

 

The next time you are writing up an HTML form, think twice before making the form fields align to the right or left of their labels.  This can make a difference in how easy it is for your user to fill out the form.  Here’s a great visualization that explains:

 

Free Apps

Free is an amazing word! I decided to compile a list of 100+ of the very best free apps for Windows, Mac, and Linux. Not all of the free apps listed work on all platforms…so make sure to look into it on your own. This list is broken down into 11 pages. Each page accounts for a software category. Feel free to leave additional free apps that you like in the comments!

Categories:

 

Most people who need a website don’t actually know whether to hire a web designer or a web developer. In fact, most people don’t even know the difference between the two. So which one should you hire?

If a website is to be successful, it requires the talents of both. While, the work of a web designer and the work of a web developer have some similarities, there are also some very distinct differences between the two. Web design is the art of conceptualizing a design idea and bringing it to life on the web. Web development is the in-depth technical work that makes everything function the way it is supposed to.

It is very common for a web developer to have skills in design. In fact, one could say that web design is actually a sub-skill of web development. On the other hand, web designers are much less likely to have the skills necessary to write the markup and coding of a complex site. Designers tend to be dependent on developers, while developers tend to be independent and capable of doing an entire job from concept to finished product.

When it comes to the presentation of content, a designer might have many more creative ideas than a developer. This is not always true, but designer tend to be artists while developers tend to be more analytical. So, which one should you hire? Well, the ideal is a web developer with strong design and creative skills. I always recommend hiring a designer to help with the initial layout ideas and even creating a mockup of the final product. That is when you bring the developer in.

I hope this helps someone understand the difference between web design and web development!

 

HTML colors are defined using hexadecimal values for the combination of Red, Green, and Blue. Here’s a helpful chart:

HTML Colors – A Complete Guide

© 2011 Tech Remedy Suffusion theme by Sayontan Sinha