Free Code Samples!
Having no formal training in HTML, CSS, PHP, JavaScript, and jQuery, I’ve had
to figure out most things from books and Web sites. So many explanations leave out
essential information as if it is common knowledge, and when you try to get clarification,
some people are harsh and insulting—as if “you should already know how
to do this simple stuff.” Perhaps they believe they build themselves up
by putting others down. I’m sure they were in my position at some time
in the past. Maybe they were treated poorly by their peers and mentors. Who can say?
Nevertheless, simply by the number of people asking the same questions I ask, I’m
led to conclude two things: 1. While some of this stuff is simple, it’s not
obvious, and 2. There’s a lot of misleading and incomplete information out there.
In any case, I can usually find the information I need with some effort. My goal here
is to provide functional solutions that don’t leave you hanging with incomplete
information. Be advised, I’m no expert on most of this stuff. I don’t
claim these are the best ways of doing things, even though I follow
W3C recommendations and the recommendations of others “in-the-know” as much as possible.
It’s likely others may have better ways. I can’t even guarantee these
solutions will work for you, but these are
examples of what I’ve gotten to work for me.
Short notes
Browser
IE Browser TestingJavaScript Browser Testing
PHP Browser Testing
PHP Browser Test-1
PHP Code for Browser Test-1
PHP Browser Test-2
PHP Code for Browser Test-2
The significant difference between the above two browser tests is that Test-1
scans for a known string and uses
a sequence of conditional statements to print the name for each browser, while Test-2 uses a function to attempt
strip out the last two “words” from the “User-Agent” string.
Some might say that the code in Test-1
is a verbose and inefficient way of retrieving the browser name, but it serves as an example
demonstrating how you can take virtually any action based on the user’s browser using PHP, simply by placing
the appropriate
statements into the conditional statement in place of, or in addition to the “echo” statement.
Test-1 is also
more consistently reliable for finding specific browsers.
Test-2
is more economical in lines of code for retrieving the information but it is not as reliable since different browsers
place the salient information for browser identification in different places in the string. For example, IE and Opera
place their identifiers as the first word. I inserted specific tests for those two browsers.
Most others place it last, while Chrome’s identifier is the next to last “word” because it
actually is a Safari-based browser.
In any case, except for IE and Opera, the method retrieves the last two “words”
from the “User-Agent” string, which usually contains the
the browser name and version.
Which should you use? It depends on what you want to do.
Using .htaccess
Javascript: Set focus
Search Engine Optimization
MySQL Prevent Injection Attacks
CSS
Using CSS LinksUsing CSS Cursors
CSS Notes
Flash
Using Flash without <embed>PHP
PHP TimeZonesDate stamp
<?php
Prints something like: Saturday July 10, 2004 10:39:34 PM MT
date_default_timezone_set('America/Denver');
echo date("l, F j, Y h:i:s A");
?> MT
—This example uses Mountain time.
PHP: Headers Already Sent?
If you get the error: Cannot modify header information - headers already sent, if you have PUT ANY echo statements inside your php file remove all of them. This will most likely correct the problem.
How do I put Audio on my Web site?
I recommend two players in particular:
For individual songs, I recommend zPlayer.
You can see this demonstrated at
GoldenTracks Music -zPlayer.
For lists of songs, I recommend XSPF Player Extended. You can see this demonstrated at GoldenTracks Music -XSPF Player Exended and at SMGolden.com.
How do I put Video on my Web site?
The simplest and least expensive way is by using Windows Media Player.
I’ve documented how to do it, and I even provide a link to a text file with the code for you.

