• Questions? (908) 864-7283

Invalid SSL Certificates Will Still Provide Google Ranking Boost

Invalid SSL Certificates Will Still Provide Google Ranking Boost


Earlier on this month Google announced that SSL-secured websites will receive a small ranking boost. Since then I have even converted the majority of Rapid Purple to run over an HTTPS connection. If you've been going through the conversion process yourself ... read more

Weekly Post Roundup 8/16/2014 - 8/22/2014

Weekly Post Roundup 8/16/2014 - 8/22/2014


Discounts & Coupons HostGator's Smoke The Competition Sale Is Live! Internet News Warning: Beware Of Fake GoDaddy Emails Introducing The Bing Image Widget Marketing News 2 Weeks Left To Make The Most Of Your eCig Related Google Adwords ... read more

Warning: Beware Of Fake GoDaddy Emails

Warning: Beware Of Fake GoDaddy Emails


There is a new phishing scam that has been making the e-mail rounds this month. It's made to resemble a GoDaddy email telling you that your account has too many directories. They attempt to get you to follow a link ... read more

Introducing The Bing Image Widget

Introducing The Bing Image Widget


Bing has launched another widget for webmasters allowing you to easily incorporate image galleries and slideshows onto your website using the images within the Bing image search. You simply choose what keyword you want to pull images for, set your ... read more

2 Weeks Left To Make The Most Of Your eCig Related Google Adwords Ads

2 Weeks Left To Make The Most Of Your eCig Related Google Adwords Ads


At the start of September Google announced a change to their Google Adwords policy banning the advertisement of electronic cigarettes, airsoft guns, paintball guns, bb guns, gun scopes, ammunition ... read more

HostGator's Smoke The Competition Sale Is Live!

HostGator's Smoke The Competition Sale Is Live!


Running right now and lasting through until midnight tonight (11:59PM CST) HostGator is running a brand new flash sale giving you 45% off all new hosting packages and domain name registrations starting at just $8/year. The 45% off discount applies to all billing ... read more



Issuing SQL Statements Using PHP Data Objects

Posted on by Michael Boguslavskiy in | Leave a comment
Tags: ,

This tutorial expands upon our previous PHP Data Objects tutorial, which discusses how to connect to a MySQL database, and showcases how to communicate with that MySQL database once you are connected. Depending on the type of query you want to run you’ll be issuing statements in two different ways:

For example let’s say you need to run an SQL query to update a username within your database. This is a statement that produces no result set, and as such you would pass your SQL statement to the database handle exec() method, which will execute the statement and return the affected-row count:

$update = $dbh->exec("UPDATE users SET username = NewUsername WHERE id = 1");

If you have an SQL statement that selects rows and produces a result set you’ll want to utilize the query() method. For this example we will simply select all of the records in our users database table.

$result = $dbh->query("SELECT * FROM users");

A successful query() call returns a PDOStatement statement-handle object that is used for all operations on the result set. Some of the information available from a PDOStatement object includes the row contents and the number of columns in the result set.

We can utilize the fetch() method to return each row in our result set, in succession. If the result set is empty the fetch() method will return FALSE. In-order to get the total number of columns in our result set we can use the columnCount() method. Our next PHP Data Objects tutorial will go into detail about how the various methods available to fetch result set rows.

TGIF Post Roundup 8/3/14-8/8/2014

Posted on by Michael Boguslavskiy in | Leave a comment
Tags: , , , , ,

Connecting To A Database Using PHP Data Objects

Posted on by Michael Boguslavskiy in | Leave a comment
Tags: ,

With the release of PHP 5.5.0 the mysql_* functions have become deprecated and as such connecting to a MySQL database with PHP 5.5 and up will require the use of either PHP Data Objects (PDO) or an individual MySQL driver (MySQLi). Throughout this tutorial we will focus on utilizing PDO to connect, access, and disconnect from a MySQL database. If you’re hosting provider is running an older version of PHP than 5.5 please refer to our older tutorial about connecting to a MySQL database.

To establish a connection to a MySQL server, specify a data source name (DSN) containing connection parameters, and optionally the username and password of the MySQL account to use. For MySQL, the DSN is a string that indicates the database driver (mysql), and optionally the hostname where the server is running and the name of the database to use. Typical syntax for the DSN looks like this:

mysql:host=host_name;dbname=db_name

The default host is localhost. If dbname is omitted, no default database is selected. The MySQL driver also recognizes port and unix_socket parameters, which specify the TCP/IP port number and Unix socket file pathname, respectively. If you use unix_socket, do not specify host or port. For other database engines, the driver name is different (for example, pgsql for PostgreSQL) and the parameters following the colon might be different as well.

To connect to the MySQL server on the local host to access a database called test with a username and password of testuser and testpass, the connection sequence looks like this:

$dbh = new PDO("mysql:host=localhost;dbname=test", "testuser", "testpass");

When you invoke the new PDO() constructor method to connect to your database server, PDO determines from the DSN which type of database engine you want to use and accesses the low-level driver appropriate for that engine. This is similar to the way that Perl or Ruby DBI scripts reference only the top-level DBI module; the connect() method provided by the top-level module looks at the DSN and determines which particular lower-level driver to use.

If new PDO() fails, PHP throws an exception. Otherwise, the constructor method returns an object of the PDO class. This object is a database handle that you use for interacting with the database server until you close the connection.

When you’re done using the connection, close it by setting the database handle to NULL:

$dbh = NULL;

After that, $dbh becomes invalid as a database handle and can no longer be used as such. If you do not close the connection explicitly, PHP does so when the script terminates.

TGIF Post Roundup 7/27/14-8/2/14

Posted on by Michael Boguslavskiy in | Leave a comment
Tags: , , , , , ,

You know I couldn’t tell you why I never put together these end-of-the-week roundup posts but I should have been doing so for a long time. See I myself rarely have time to truly keep up with all the news throughout the week and as such I often catch up on the weeks worth of news and events during the weekend. So with that acknowledged I’m going to start writing weekly round-up posts every Friday to give a quick overview of the past week’s news.

Including Another File Within Your Script

Posted on by Michael Boguslavskiy in | Leave a comment
Tags: , ,

Almost all online scripts and applications will feature a core library of variables and functions that get utilized throughout the script. For example, let’s say you’re writing a database intensive application. You could declare your MySQL details within each page of your script – however if you ever changed your password that would mean that you would need to update every single page of your script with the new MySQL details. Rather than declaring the password in each of your page scripts, you can store that name and password in a separate file. You can then include that file as a part of your script, and whatever variables you declare in that file will be declared in your script! Furthermore, you can store long scripts or functions in a separate file and include them only when you need them. For example, if you are writing an eCommerce shopping cart script the function that gets real-time UPS shipping quotes is 24KB worth of XML processing goodness, but you use it only when someone chooses UPS as a shipping option. Why not store it in ups_ship_quotes.php and call it only when necessary?

In fact, almost all heavy-duty PHP applications have a file called something like config.php, which declares the critical variables that every page needs to know, such as the MySQL name and password. Those same applications also store frequently used scripts in different directories. Programmers then mix and match, taking the check-to-see-if-a-user-is-logged-in script from one directory, including the get-the-relevant-data-from-the-database script from another directory, and writing a central script that screens the data based on whether the user is logged in or not.

So let’s dig into how we can do the same.

require_once("/path/to/file.php");

The file that you pass through to require_once() is now a part of your script, exactly as if you had cut and copied the contents of the file into your script. You can even include HTML files to create a simple templating system.

PHP will interpret any file you pass through as PHP code – so make sure you have your opening and closing php tags (<?php ?>) around the PHP code in your included file, otherwise PHP will simply print the entire file.

(more…)

Making Life Easier with PHP While Loops

Posted on by Michael Boguslavskiy in | Leave a comment
Tags: , ,

The WHILE loop is one of the most useful commands in PHP. It is also quite easy to set up and use – granted it might look a bit complicated. First off however let’s figure out just what the hell a WHILE loop is – and what we need it for. A WHILE loop will, as the name suggests, execute a piece of code while a certain condition is met. So – what’s the point? WHILE loops make repetitive tasks much less annoying than they usually are. Let’s take a look at a few simple examples.

Making Bart Simpsons Life Easier

Let’s say you have a specific bit of code that you need to repeat several times. You can sit there and manually type everything out; or you can use a WHILE loop. I’m sure most of us here have watched the Simpsons at some point or another right? Remember how Bart is always writing something over and over again on a blackboard in the opening of each episode? Let’s use that as an example. Assume we need to write “I will not pledge allegiance to Bart.” 50 times on our website. We can utilize the WHILE loop to ECHO that specific text 50 times:

$times = 50; 
$x = 0; 
while ($x &lt; $times) { 
echo "I will not pledge allegiance to Bart. "; 
++$x; 
}

So, first we set the $times variable which holds the number of times we want to repeat our text. Then we set the $x variable which is the one that will count the number of times the code has been executed. After these is where the WHILE loop comes into play. On line 3 we tell the server to repeat the code while $x is less than $times. This is followed by the code to be executed which is enclosed in { }.

After the echo line which prints out the text, there is another very important line:

++$x;

What this does is exactly the same as writing:

$x = $x + 1;

It adds one to the value of $x. This code is then repeated (as $x now equals 1). It continues being repeated until $x equals 50 (the value of times) at which point the while loop will stop. Now if we could just figure out how to get Bart a digital blackboard – he can start programming WHILE loops in PHP instead of wasting all that chalk.

Making Life Easier with PHP While Loops / php tutorials  / 1x1.trans

(more…)

Sending Mail with PHP

Posted on by Michael Boguslavskiy in | Leave a comment
Tags: , ,

Mail is extremely easy to send from PHP, unlike using scripting languages which require special setup (like CGI). There is actually just one command, mail() for sending mail. In this tutorial we will discuss how to use PHP’s mail() function. It is used as follows:

mail($to,$subject,$body,$headers);

In this example I have used variables as they have descriptive names but you could also just place text in the mail command. Firstly, $to. This variable (or section of the command) contains the e-mail address to which the mail will be sent. $subject is the section for the subject of the e-mail and $body is the actual text of the e-mail.

The section $headers is used for any additional e-mail headers you may want to add. The most common use of this is for the From field of an e-mai but you can also include other headers like cc and bcc.

Sending An E-mail

Before sending your mail, if you are using variables, you must, of course, set up the variable content beforehand. Here is some simple code for sending a message:

$to = "[email protected]"; 
$subject = "PHP Is Great"; 
$body = "PHP is one of the best scripting languages around"; 
$headers = "From: [email protected]\n"; 
mail($to,$subject,$body,$headers); 
echo "Mail sent to $to";

This code will acutally do two things. Firstly it will send a message to ‘[email protected] with the subject ‘PHP Is Great‘ and the text: PHP is one of the best scripting languages around. The e-mail will be from ‘[email protected]’ and it will also output the following text: ‘Mail sent to [email protected] to the browser.

Formatting E-mail

Something you may have noticed from the example is that the From line ended with \n. This is acutally a very important character when sending e-mail. It is the new line character and tells PHP to take a new line in an e-mail. It is very important that this is put in after each header you add so that your e-mail will follow the international standards and will have no issues in being delivered.

The \n code can also be used in the body section of the e-mail to put line breaks in but should not be used in the subject or the tofield.

Mail Without Variables

The e-mail above could have been sent using different variable names (it is the position of the variables in relation to the commas, not the name of them which decides on their use). It could also have been done on one line using code like this:

mail("[email protected]","PHP Is Great","PHP is one of the best scripting languages around","From: [email protected]\n");

But that would make your code slightly harder to read.

Error Control

As anyone who has been scripting for a while will know, it is extremely easy to make mistakes in your code and it is also very easy to input an invalid e-mail address (especially if you are using your script for form to mail). Because of this, you can (and should) add in a small piece of code which will check if the e-mail is sent:

if(mail($to,$subject,$body,$headers)) { 
echo "An e-mail was sent to $to with the subject: $subject"; 
} else { 
echo "There was a problem sending the mail. Check your code and make sure that the e-mail address $to is valid"; 
}

This code is quite self explanitory. If the mail is sent successfully it will output a message to the browser telling the user, if not, it will display an error message with some suggestions for correcting the problem. Here is a complete mail script:

$to = "[email protected]"; 
$subject = "PHP Is Great"; 
$body = "PHP is one of the best scripting languages around"; 
$headers = "From: [email protected]\n";
if(mail($to,$subject,$body,$headers)) { 
echo "An e-mail was sent to $to with the subject: $subject"; 
} else { 
echo "There was a problem sending the mail. Check your code and make sure that the e-mail address $to is valid"; 
}

PHP Tutorials

Posted on by Michael Boguslavskiy in | Leave a comment
Tags: ,

Looking to dive into the wonderful world of PHP & MySQL? The following tutorials should help you get started.

The Basics

Echo();

Chances are you’re familiar with the Hello World exercise by now. It’s the starting point for learning almost any programming language. PHP is no different. So let’s dive right into it. How do we display things using PHP?

Variables

If you have ever looked through any programming language – or still remember those algebra classes when you learned what 3+x=5 means. A variable stores something inside of it so that you can recall it later on in your scripting. So let’s take a look at creating variables and storing information in them through PHP.

Escaping Characters & Variable Expansion

Escaping characters is rather basic, however understanding how it functions together with various variables is essential to an error-free PHP script.

How Functions Work

A function is merely a block of code that can be defined once and then reused throughout various other parts of your script/program. Throughout this tutorial we will take a look at exactly how PHP functions are written.

The Ternary Operator

PHP has plenty of different operators, the majority of them being either unary or binary operators. A unary operator, such as !, performs its operations on just one single value. A binary operator, such as =, is used to perform an operation on two operads. So following the naming logic you’ve probably already figured out that a PHP ternary operator performs a single operation on three different values.

Making Life Easier with While Loops

The WHILE loop is one of the most useful commands in PHP. It is also quite easy to set up and use – granted it might look a bit complicated. First off however let’s figure out just what the hell a WHILE loop is – and what we need it for. A WHILE loop will, as the name suggests, execute a piece of code while a certain condition is met. So – what’s the point? WHILE loops make repetitive tasks much less annoying than they usually are.

Include Another File Within Your Script

The ability to include additional files within your PHP script is crucial for proper managing & organizing your code. For example, if you are writing an eCommerce shopping cart script the function that gets real-time UPS shipping quotes is 24KB worth of XML processing goodness, but you use it only when someone chooses UPS as a shipping option. Why not store it in ups_ship_quotes.php and call it only when necessary? Let’s learn how.

Sending Email with PHP

Mail is extremely easy to send from PHP, unlike using scripting languages which require special setup (like CGI). There is actually just one command, mail() for sending mail. In this tutorial we will discuss how to use PHP’s mail() function.

Real World Examples

Connecting to a MySQL Database

None of our previous PHP tutorials have dealt with a database yet, and that is for the sole reason that not everyone has access to a database, however for those who do this tutorial will teach you the basics on how you can connect to your database.

Connecting to a MySQL Database Using PHP Data Objects

With the release of PHP 5.5.0 the mysql_* functions have become deprecated and as such connecting to a MySQL database with PHP 5.5 and up will require the use of either PHP Data Objects (PDO) or an individual MySQL driver (MySQLi). Throughout this tutorial we will focus on utilizing PDO to connect, access, and disconnect from a MySQL database.

Issuing Statements to a MySQL Database Using PHP Data Objects

This tutorial expands upon our previous PHP Data Objects tutorial, which discusses how to connect to a MySQL database, and showcases how to communicate with that MySQL database once you are connected.

File Upload via PHP/MySQL

As per the request of Spaculus I have decided to put together a tutorial discussing how to upload an image to your server, and store the information about that uploaded image into your MySQL database.

File Upload via PHP/MySQL – Error Checking

This tutorial aims to expand upon the basic file upload functionality that was discussed previously and introduces various error checking features for file size, and file types, etc.

Basic PHP Template System

PHP has many different template solutions, and the beauty of them all is how simple it makes maintaining and changing your website. Back in the day when everything was handled with static HTML files – if you needed to add a new link to your main menu – you found yourself editing dozens if not hundreds of different files.  With PHP you can break up your website into several sections, includes if you will. So the menu code can all be within 1 single file, which you include on other pages.

Display Page Loading Time

Have you ever noticed that lots of websites feature some text towards the very bottom of a page saying “Page took x.xxx seconds to load”? It’s a pretty simple thing to make and gives your site something that we all love … stats!

Linux Server Tutorials

Posted on by Michael Boguslavskiy in | Leave a comment
Tags: , ,

As a webmaster chances are you will wind up managing a Linux box or two in your time – and when you do you’ll be happy you learned these tricks.

The Bash Shell

Pipelines

Discover how to use pipelines to string together a series of commands. This means that the output from the first command in the pipeline is used as the input for the second command in the pipeline. The output from the second command in the pipeline is used as the input to the third command in the pipeline, and so on, and so on.

Command History & Aliases

Learn how Bash keeps track of a certain number of previous commands that you have entered into the shell via the History; and see how Bash makes life easier for you is by supporting command aliases – commands that the user can specify.

Wildcards & Command Line Completion

Learn how to use wildcards and command line completion to make your life programming within Bash that much easier.

Server Security

Turn Off RWHOD

The rwhod daemon is a process that allows a remote user to see who is logged into your system. The client program is rwho. It has many of the same security problems as the finger daemon. For a cracker use of rwho could allow him to watch for times on your system when nobody is logged in and begin his attacks. Learn how to turn off RWHOD on your server.

Trojan Port List

A detailed list which shows the majority of the more popular known trojans, and the ports they normally use.

Processes & How To Terminate Them

Learn how to be able to view all the running processes, or stop a program if it hits a bug or a flaw.

Getting Started with HTML

Posted on by Michael Boguslavskiy in | Leave a comment
Tags: ,

HTML is the basic language used to create web pages. In fact the majority of what you see right now, on your screen, was created through the use of HTML. The tutorials listed within this section will help you get a grasp on some of the key basics of HTML programming; and then continue on to touch upon some more advanced topics that tie in the use of CSS and Javascript with HTML to create more dynamic content types.

Text Formatting

Learn how to manipulate your websites text content by controlling the text size, color, and font type. Furthermore learn how to place emphasis on certain parts through the help of <b>, <i>, and <u> tags.

HTML Entities

Some characters have a special meaning in HTML, like the less than sign (<) that defines the start of an HTML tag. If we want the browser to actually display these characters we must insert character entities in the HTML source.

Creating Links

HTML uses the <a> (anchor) tag to create a link to another document. An anchor can point to any resource on the Web: an HTML page, an image, a sound file, a movie, etc. Learn how to make the most of links in HTML.

HTML Image Maps

An image map is a graphic that has more than one hyperlink attached to it. They hyperlink that the viewer will follow when clicking on the image depends on which part of they click on. This tutorial will discuss in depth how to create your own HTML image maps.

Proper Use of Heading, ALT & Title Tags

This HTML tutorial covers 3 extremely useful tags and attributes that most people overlook, or do not take advantage of properly. These are the alt tags, title attributes in links and heading tags.

Night & Day Detection

If we assume that people’s interests vary according to the time of day, your website might be well served by promoting different kinds of content depending on whether its day or night. For example lets say we have two articles, one about the sun eventually burning out, and one about the Hale-Bopp comet. We can make the main article be the sun in daytime, and the comet at nighttime. In this tutorial we are going to use javascript to achieve this effect.

Square CSS Badges

I was playing around with CSS earlier today and came up with something rather interesting, I call them CSS badges since I’m really not sure what else to call them.The code behind these buttons is actually extremely simple and I have commented it along the way so you could easily see what controls what.

1 2 3 4 5 6 7 8 9 10   Next »

Sign Up To Our Newsletter

  • Stay Updated With All The Latest Webmaster News
  • Be The First To Hear Of New Hosting & Domain Name Coupons & Sales
  • Get Exclusive Webmaster Freebies

Sign up today and I'll send you a free gift!

Stay Connected With Us

Stay in touch with us by following us on Facebook, Twitter, and Google+. There's always plenty of new articles being shared that you won't find within the Rapid Purple blog.