Web Development Blog

Check for Cookies Enabled

September 11th, 2011

I recently needed to check and see if cookies were enabled for a script that I was writing for authenticating a user login. I quickly realized all the problems with this I had forgot as I don’t normally set cookies but rather normally use sessions.

Problems to overcome:

  1. Can’t check for a cookie when first setting the cookie - you have to reload the page to check for it. It would make sense to set a cookie and then in your next lines of code to check if there is a cookie, thus telling you cookies are enabled if you can pull the cookie back up. Unfortunately that will not work, you have to reload the page to check for the cookie. So this method is not a good one for what I’m doing.
  2. Don’t have to reload the browser – since about I pointed out that I have to reload a page to check for a cookie I just set I’d like to find a method were I don’t have to reload the page.
  3. No JavaScript enabled – would like to check for cookies with JavaScript. Although is not absolutely necessary for my needs so if I have to I’ll check it with JavaScript.

What I came up with:

I found several ways to check for cookies with both JavaScript and at least one way with PHP.

JavaScript:

var cookiesEnabled = (navigator.cookiesEnabled) ? true : false;

PHP:

setcookie("cookiesEnabled",1,time()+3600*24);
// Above cookie expires in 24 hours
// Next you have to reload the page to test the next part, so on first load below will give false even if cookies is enabled
$cookiesEnabled = (isset($_COOKIE['cookiesEnabled'])) ? true : fasle;

Best Method:

Below are the best methods I could come up with. I’ve create both a PHP and Javascript method. JavaScript should be cross-browser safe. Although PHP does rely on that the page being reloaded – which for a login page that should be the case.

Using JavaScript:

function isCookiesEnabled()
{
 var cookiesEnabled = (navigator.cookiesEnabled) ? true : false;
 if(typeof navigator.cookiesEnabled=="undefined" && !cookiesEnabled)
 {
  document.cookie="testcookie";
  cookiesEnabled = (document.cookie.indexOf("testcookie") != -1) ? true : false;
 }
 return (cookiesEnabled);
}

Using PHP:

// Setup Cookies Enabled Check
setcookie("cookiesEnabled",1,time()+3600*24,'/','.'.$_SERVER['SERVER_NAME']); // set for 24 hours

// Check Cookies Enabled
 $cookiesEnabled = (isset($_COOKIE['cookieEnabled'])) ? true : false;

Netflix Instant Play Bugs – Buffer Rate Issues & More

June 27th, 2011

Being a web developer I’m well aware that sites developed need to be checked over with a fine-tooth-comb for bug and potential issues. In fact there are even many times when you can check for bugs and even check the site in many different Internet browsers (such as Firefox, Internet Explorer, Google Chrome, Safari, ect…) and still miss things just because your computer might have some slightly different settings which make some sort of bug not present on your computer but still show up on many of the end users’ computers. It bites! But one successful thing is to listen to users and investigate what they report. I’ve found most of the time the user is correct even if I could not reproduce the issue on my end – it usually turns out other people are having the same issue and just didn’t speak up about it.

So with that said I’m hoping someone from Netflix (particular the web development or engineering team) will look this blog post over, take it to heart and investigate these issues. I became a Netflix member about 2 months ago and so far like the service but the bugs I found make it almost impossible to watch anything “Instant” unless you want to spend extra time trying to combat bugs and are forced to refresh the page many times and keep fiddling with the Silverlight settings.

So to get on with it, here are several bugs I’ve found with the Netflix Silverlight player. These are issues not specific to any one video but rather issues experienced them on numerous videos as well as in several browsers (Firefox, IE and Chrome).

1. The buffer rate and play rate tend to become the same rate. This means when you try to play something it’s buffering at the same rate it’s playing – thus choppy video! The buffer rate should be bigger than the play rate in order to keep the video buffered enough in advance so the play back is smooth. I’ve even tried to manually change the buffer rate (via the Silverlight setting, shift + alt + right click) and moved the video playback track around so the new buffer rate would take effect (another trick I’ve found you have to do) plus enabling the GPU Acceleration but that only helps for a little while and the rates eventually match each other again and cause playback issues.

2. Also recently (similar to he above issue) it seems there is some other play back or buffering issues going on too. As I’ve noticed that when you first start a video it plays for a few minutes or so and then has to buffer/load but the buffer time starts out loading at a good speed but then slows down and takes for ever to buffer/load. But if I just refresh when this happens the page the load/buffer time is considerably quicker. So there is something going on with buffering.

3. There are some issues with the player going full screen and back to normal. Sometimes I’ll get a tiled view (or like window blinds, see picture below) where the picture is distorted horizontally. Sometimes it happens when I click full screen, other times when I click to exit full screen (or click Esc button on keyword). This does not happen all the time but usually is corrected by clicking full screen then existing full screen and back again several times until picture looks normal.

Netflix bug - window blinds

4. Can’t change play track position while loading/buffering (aka, during the screen with the red loading bar going across video). When the video is loading/buffering (even when video stops during play back to load/buffer video) I can’t change the play track position. The video track and all other Silverlight features (can’t use shift + alt + right click) are locked. This is a pain if you want to change the video track (position in video were you are playing from) and the loading/buffering bar is there as you have to wait till it’s done which could take a while then you click to another point on the video track and it’s got to do it all over again (same if need to change a setting in Sliverlight)… aggg

5. More things to come as I find them… above are 4 of the most important for now.

Also if you know of anything please feel free to post your bugs/issues in the comments. Hopefully this will at least get these above items fixed.

[FIXED] ib is null – ibrowser Plugin for TinyMCE

January 21st, 2011

I, like you, have run into the problem of ibrowser not working for Firefox (FF3). This is a pain as it seems like a great free image uploaded/manager for TinyMCE. The problem I kept running it is that after installing ibrowser and then testing it out, is that the icon to open up the popup for this plugin does nothing. Under further investigation I discovered I was getting a JavaScript error “ib is null“.

Well, so I search Google and found some people saying to add “var ib = null;” (no quotes) to the beginning of the editor_plugin.js. I opened my editor_plugin.js file and see that for my version this bug fix is already in there (aka ib = null; as already pasted into the beginning of this file). So back to square one, problem still not solved.

Then I looked through the code and found that the issue seems to be that on line 14 (of my version) which reads tinymce.ScriptLoader.load(url + ‘/interface/common.js’); this is not actually loading the script. So I just commented that line out and copied and pasted that whole script under that line.

That seemed to work and I got the ibrowser to open and upload images. But it would now not insert the image into the editor when you click the insert button. And I saw that I was getting the JavaScript error “opner.ibrowser_callback is not a function” now.

So this copy and paste method was not really working. I realized then that if the problem is that its just not loading the script then I should add in some code that will load the script for me.

[SOLUTION]

I’m luckly already using jQuery so I just did the following:

  1. In the file editor_plugin.js (located in ibrowser root plugin folder) commented out the line:
    tinymce.ScriptLoader.load(url + '/interface/common.js');
  2. Added the following line after that:
    $.getScript(url+'/interface/common.js'); // BUG FIX by Sean Gallagher www.GallagherWebsiteDesign.com
  3. Do the same as the above 2 steps for editor_plugin_src.js file as well
  4. That’s it! Upload editor_plugin.js and editor_plugin_src.js to your server and your done.

For non-iQuery users try the following solution – I’ve not tried this but others said it worked.

  1. In the file editor_plugin.js (located in ibrowser root plugin folder) commented out the line:
    tinymce.ScriptLoader.load(url + '/interface/common.js');
  2. Added the following line after that:
    tinymce.ScriptLoader.add(url + '/interface/common.js'); tinymce.ScriptLoader.loadQueue();
  3. Do the same as the above 2 steps for editor_plugin_src.js file as well
  4. That’s it… for more on this solution check out the TinyMCE forum thread for this (this solution is on the last page of that thread).

For more on jQUery script loading check out the getScript function.

To download ibrowser visit visions4net.com’s download page.

To download TinyMCE check out the TinyMCE home page.

HTML State Dropdown List with PHP Dynamic Select

July 15th, 2010

I’m always running into a project were I am setting up a sign up form or something and need a HTML state dropdown list for the 50 US states but also needs to include a PHP based dynamicly select/checked based on what the user submited. For example, when someone submits a form and it faild validation and you want to show the form again but don’t want the user to have to reselect that checkbox, select option or radio option again. This handy script dynamically checks/selects the right one based off what the user submitted.

I’m giving this script out since it will also give me a reference to quickly use it myself in projects as well as provided it to you.

So here goes… The following first code is my custom PHP function for making a checkbox, select or radio field checked dynamically based on what was submitted. Then following that is the 50 U.S. states dropdown list in both an abbreviation and non abbreviation format. As an added bonus I’ve also included a select dropdown list for countries.

PHP Function


<?php
############################
# Dynamic Form Fields Func #
############################
function dynField($option,$value,$type)
{
 if($type=='checkbox' && @in_array($value,$option)) { echo ' CHECKED'; return; }
 if($option==$value)
 {
  if($type=='option') { echo ' SELECTED'; }
  if($type=='radio') { echo ' CHECKED'; }
 }
}
?>

HTML Select Dropdown

States Non-Abbreviated Format


<select name="state">
 <option value="AL"<?php dynField(@$state,'AL','option'); ?>>Alabama</option>
 <option value="AK"<?php dynField(@$state,'AK','option'); ?>>Alaska</option>
 <option value="AZ"<?php dynField(@$state,'AZ','option'); ?>>Arizona</option>
 <option value="AR"<?php dynField(@$state,'AR','option'); ?>>Arkansas</option>
 <option value="CA"<?php dynField(@$state,'CA','option'); ?>>California</option>
 <option value="CO"<?php dynField(@$state,'CO','option'); ?>>Colorado</option>
 <option value="CT"<?php dynField(@$state,'CT','option'); ?>>Connecticut</option>
 <option value="DE"<?php dynField(@$state,'DE','option'); ?>>Delaware</option>
 <option value="DC"<?php dynField(@$state,'DC','option'); ?>>District of Columbia</option>
 <option value="FL"<?php dynField(@$state,'FL','option'); ?>>Florida</option>
 <option value="GA"<?php dynField(@$state,'GA','option'); ?>>Georgia</option>
 <option value="HI"<?php dynField(@$state,'HI','option'); ?>>Hawaii</option>
 <option value="ID"<?php dynField(@$state,'ID','option'); ?>>Idaho</option>
 <option value="IL"<?php dynField(@$state,'IL','option'); ?>>Illinois</option>
 <option value="IN"<?php dynField(@$state,'IN','option'); ?>>Indiana</option>
 <option value="IA"<?php dynField(@$state,'IA','option'); ?>>Iowa</option>
 <option value="KS"<?php dynField(@$state,'KS','option'); ?>>Kansas</option>
 <option value="KY"<?php dynField(@$state,'KY','option'); ?>>Kentucky</option>
 <option value="LA"<?php dynField(@$state,'LA','option'); ?>>Louisiana</option>
 <option value="ME"<?php dynField(@$state,'ME','option'); ?>>Maine</option>
 <option value="MD"<?php dynField(@$state,'MD','option'); ?>>Maryland</option>
 <option value="MA"<?php dynField(@$state,'MA','option'); ?>>Massachusetts</option>
 <option value="MI"<?php dynField(@$state,'MI','option'); ?>>Michigan</option>
 <option value="MN"<?php dynField(@$state,'MN','option'); ?>>Minnesota</option>
 <option value="MS"<?php dynField(@$state,'MS','option'); ?>>Mississippi</option>
 <option value="MO"<?php dynField(@$state,'MO','option'); ?>>Missouri</option>
 <option value="MT"<?php dynField(@$state,'MT','option'); ?>>Montana</option>
 <option value="NE"<?php dynField(@$state,'NE','option'); ?>>Nebraska</option>
 <option value="NV"<?php dynField(@$state,'NV','option'); ?>>Nevada</option>
 <option value="NH"<?php dynField(@$state,'NH','option'); ?>>New Hampshire</option>
 <option value="NJ"<?php dynField(@$state,'NJ','option'); ?>>New Jersey</option>
 <option value="NM"<?php dynField(@$state,'NM','option'); ?>>New Mexico</option>
 <option value="NY"<?php dynField(@$state,'NY','option'); ?>>New York</option>
 <option value="NC"<?php dynField(@$state,'NC','option'); ?>>North Carolina</option>
 <option value="ND"<?php dynField(@$state,'ND','option'); ?>>North Dakota</option>
 <option value="OH"<?php dynField(@$state,'OH','option'); ?>>Ohio</option>
 <option value="OK"<?php dynField(@$state,'OK','option'); ?>>Oklahoma</option>
 <option value="OR"<?php dynField(@$state,'OR','option'); ?>>Oregon</option>
 <option value="PA"<?php dynField(@$state,'PA','option'); ?>>Pennsylvania</option>
 <option value="RI"<?php dynField(@$state,'RI','option'); ?>>Rhode Island</option>
 <option value="SC"<?php dynField(@$state,'SC','option'); ?>>South Carolina</option>
 <option value="SD"<?php dynField(@$state,'SD','option'); ?>>South Dakota</option>
 <option value="TN"<?php dynField(@$state,'TN','option'); ?>>Tennessee</option>
 <option value="TX"<?php dynField(@$state,'TX','option'); ?>>Texas</option>
 <option value="UT"<?php dynField(@$state,'UT','option'); ?>>Utah</option>
 <option value="VT"<?php dynField(@$state,'VT','option'); ?>>Vermont</option>
 <option value="VA"<?php dynField(@$state,'VA','option'); ?>>Virginia</option>
 <option value="WA"<?php dynField(@$state,'WA','option'); ?>>Washington</option>
 <option value="WV"<?php dynField(@$state,'WV','option'); ?>>West Virginia</option>
 <option value="WI"<?php dynField(@$state,'WI','option'); ?>>Wisconsin</option>
 <option value="WY"<?php dynField(@$state,'WY','option'); ?>>Wyoming</option>
</select>

States Abbreviated Format


<select name="state">
 <option value="AL"<?php dynField(@$state,'AL','option'); ?>>AL</option>
 <option value="AK"<?php dynField(@$state,'AK','option'); ?>>AK</option>
 <option value="AZ"<?php dynField(@$state,'AZ','option'); ?>>AZ</option>
 <option value="AR"<?php dynField(@$state,'AR','option'); ?>>AR</option>
 <option value="CA"<?php dynField(@$state,'CA','option'); ?>>CA</option>
 <option value="CO"<?php dynField(@$state,'CO','option'); ?>>CO</option>
 <option value="CT"<?php dynField(@$state,'CT','option'); ?>>CT</option>
 <option value="DE"<?php dynField(@$state,'DE','option'); ?>>DE</option>
 <option value="DC"<?php dynField(@$state,'DC','option'); ?>>DC</option>
 <option value="FL"<?php dynField(@$state,'FL','option'); ?>>FL</option>
 <option value="GA"<?php dynField(@$state,'GA','option'); ?>>GA</option>
 <option value="HI"<?php dynField(@$state,'HI','option'); ?>>HI</option>
 <option value="ID"<?php dynField(@$state,'ID','option'); ?>>ID</option>
 <option value="IL"<?php dynField(@$state,'IL','option'); ?>>IL</option>
 <option value="IN"<?php dynField(@$state,'IN','option'); ?>>IN</option>
 <option value="IA"<?php dynField(@$state,'IA','option'); ?>>IA</option>
 <option value="KS"<?php dynField(@$state,'KS','option'); ?>>KS</option>
 <option value="KY"<?php dynField(@$state,'KY','option'); ?>>KY</option>
 <option value="LA"<?php dynField(@$state,'LA','option'); ?>>LA</option>
 <option value="ME"<?php dynField(@$state,'ME','option'); ?>>ME</option>
 <option value="MD"<?php dynField(@$state,'MD','option'); ?>>MD</option>
 <option value="MA"<?php dynField(@$state,'MA','option'); ?>>MA</option>
 <option value="MI"<?php dynField(@$state,'MI','option'); ?>>MI</option>
 <option value="MN"<?php dynField(@$state,'MN','option'); ?>>MN</option>
 <option value="MS"<?php dynField(@$state,'MS','option'); ?>>MS</option>
 <option value="MO"<?php dynField(@$state,'MO','option'); ?>>MO</option>
 <option value="MT"<?php dynField(@$state,'MT','option'); ?>>MT</option>
 <option value="NE"<?php dynField(@$state,'NE','option'); ?>>NE</option>
 <option value="NV"<?php dynField(@$state,'NV','option'); ?>>NV</option>
 <option value="NH"<?php dynField(@$state,'NH','option'); ?>>NH</option>
 <option value="NJ"<?php dynField(@$state,'NJ','option'); ?>>NJ</option>
 <option value="NM"<?php dynField(@$state,'NM','option'); ?>>NM</option>
 <option value="NY"<?php dynField(@$state,'NY','option'); ?>>NY</option>
 <option value="NC"<?php dynField(@$state,'NC','option'); ?>>NC</option>
 <option value="ND"<?php dynField(@$state,'ND','option'); ?>>ND</option>
 <option value="OH"<?php dynField(@$state,'OH','option'); ?>>OH</option>
 <option value="OK"<?php dynField(@$state,'OK','option'); ?>>OK</option>
 <option value="OR"<?php dynField(@$state,'OR','option'); ?>>OR</option>
 <option value="PA"<?php dynField(@$state,'PA','option'); ?>>PA</option>
 <option value="RI"<?php dynField(@$state,'RI','option'); ?>>RI</option>
 <option value="SC"<?php dynField(@$state,'SC','option'); ?>>SC</option>
 <option value="SD"<?php dynField(@$state,'SD','option'); ?>>SD</option>
 <option value="TN"<?php dynField(@$state,'TN','option'); ?>>TN</option>
 <option value="TX"<?php dynField(@$state,'TX','option'); ?>>TX</option>
 <option value="UT"<?php dynField(@$state,'UT','option'); ?>>UT</option>
 <option value="VT"<?php dynField(@$state,'VT','option'); ?>>VT</option>
 <option value="VA"<?php dynField(@$state,'VA','option'); ?>>VA</option>
 <option value="WA"<?php dynField(@$state,'WA','option'); ?>>WA</option>
 <option value="WV"<?php dynField(@$state,'WV','option'); ?>>WV</option>
 <option value="WI"<?php dynField(@$state,'WI','option'); ?>>WI</option>
 <option value="WY"<?php dynField(@$state,'WY','option'); ?>>WY</option>
</select>

Country List


<select name="country">
 <option value="AF"<?php dynField(@$country,'AF','option'); ?>>Afghanistan</option>
 <option value="AL"<?php dynField(@$country,'AL','option'); ?>>Albania</option>
 <option value="DZ"<?php dynField(@$country,'DZ','option'); ?>>Algeria</option>
 <option value="AS"<?php dynField(@$country,'AS','option'); ?>>American Samoa</option>
 <option value="AD"<?php dynField(@$country,'AD','option'); ?>>Andorra</option>
 <option value="AO"<?php dynField(@$country,'AO','option'); ?>>Angola</option>
 <option value="AI"<?php dynField(@$country,'AI','option'); ?>>Anguilla</option>
 <option value="AQ"<?php dynField(@$country,'AQ','option'); ?>>Antarctica</option>
 <option value="AG"<?php dynField(@$country,'AG','option'); ?>>Antigua and Barbuda</option>
 <option value="AR"<?php dynField(@$country,'AR','option'); ?>>Argentina</option>
 <option value="AM"<?php dynField(@$country,'AM','option'); ?>>Armenia</option>
 <option value="AW"<?php dynField(@$country,'AW','option'); ?>>Aruba</option>
 <option value="AU"<?php dynField(@$country,'AU','option'); ?>>Australia</option>
 <option value="AT"<?php dynField(@$country,'AT','option'); ?>>Austria</option>
 <option value="AZ"<?php dynField(@$country,'AZ','option'); ?>>Azerbaijan</option>
 <option value="BS"<?php dynField(@$country,'BS','option'); ?>>Bahamas</option>
 <option value="BH"<?php dynField(@$country,'BH','option'); ?>>Bahrain</option>
 <option value="BD"<?php dynField(@$country,'BD','option'); ?>>Bangladesh</option>
 <option value="BB"<?php dynField(@$country,'BB','option'); ?>>Barbados</option>
 <option value="BY"<?php dynField(@$country,'BY','option'); ?>>Belarus</option>
 <option value="BE"<?php dynField(@$country,'BE','option'); ?>>Belgium</option>
 <option value="BZ"<?php dynField(@$country,'BZ','option'); ?>>Belize</option>
 <option value="BJ"<?php dynField(@$country,'BJ','option'); ?>>Benin</option>
 <option value="BM"<?php dynField(@$country,'BM','option'); ?>>Bermuda</option>
 <option value="BT"<?php dynField(@$country,'BT','option'); ?>>Bhutan</option>
 <option value="BO"<?php dynField(@$country,'BO','option'); ?>>Bolivia</option>
 <option value="BA"<?php dynField(@$country,'BA','option'); ?>>Bosnia and Herzegowina</option>
 <option value="BW"<?php dynField(@$country,'BW','option'); ?>>Botswana</option>
 <option value="BV"<?php dynField(@$country,'BV','option'); ?>>Bouvet Island</option>
 <option value="BR"<?php dynField(@$country,'BR','option'); ?>>Brazil</option>
 <option value="IO"<?php dynField(@$country,'IO','option'); ?>>British Indian Ocean Territory</option>
 <option value="BN"<?php dynField(@$country,'BN','option'); ?>>Brunei Darussalam</option>
 <option value="BG"<?php dynField(@$country,'BG','option'); ?>>Bulgaria</option>
 <option value="BF"<?php dynField(@$country,'BF','option'); ?>>Burkina Faso</option>
 <option value="BI"<?php dynField(@$country,'BI','option'); ?>>Burundi</option>
 <option value="KH"<?php dynField(@$country,'KH','option'); ?>>Cambodia</option>
 <option value="CM"<?php dynField(@$country,'CM','option'); ?>>Cameroon</option>
 <option value="CA"<?php dynField(@$country,'CA','option'); ?>>Canada</option>
 <option value="CV"<?php dynField(@$country,'CV','option'); ?>>Cape Verde</option>
 <option value="KY"<?php dynField(@$country,'KY','option'); ?>>Cayman Islands</option>
 <option value="CF"<?php dynField(@$country,'CF','option'); ?>>Central African Republic</option>
 <option value="TD"<?php dynField(@$country,'TD','option'); ?>>Chad</option>
 <option value="CL"<?php dynField(@$country,'CL','option'); ?>>Chile</option>
 <option value="CN"<?php dynField(@$country,'CN','option'); ?>>China</option>
 <option value="CX"<?php dynField(@$country,'CX','option'); ?>>Christmas Island</option>
 <option value="CC"<?php dynField(@$country,'CC','option'); ?>>Cocos (Keeling) Islands</option>
 <option value="CO"<?php dynField(@$country,'CO','option'); ?>>Colombia</option>
 <option value="KM"<?php dynField(@$country,'KM','option'); ?>>Comoros</option>
 <option value="CG"<?php dynField(@$country,'CG','option'); ?>>Congo</option>
 <option value="CD"<?php dynField(@$country,'CD','option'); ?>>Congo, the Democratic Republic of the</option>
 <option value="CK"<?php dynField(@$country,'CK','option'); ?>>Cook Islands</option>
 <option value="CR"<?php dynField(@$country,'CR','option'); ?>>Costa Rica</option>
 <option value="CI"<?php dynField(@$country,'CI','option'); ?>>Cote d'Ivoire</option>
 <option value="HR"<?php dynField(@$country,'HR','option'); ?>>Croatia (Hrvatska)</option>
 <option value="CU"<?php dynField(@$country,'CU','option'); ?>>Cuba</option>
 <option value="CY"<?php dynField(@$country,'CY','option'); ?>>Cyprus</option>
 <option value="CZ"<?php dynField(@$country,'CZ','option'); ?>>Czech Republic</option>
 <option value="DK"<?php dynField(@$country,'DK','option'); ?>>Denmark</option>
 <option value="DJ"<?php dynField(@$country,'DJ','option'); ?>>Djibouti</option>
 <option value="DM"<?php dynField(@$country,'DM','option'); ?>>Dominica</option>
 <option value="DO"<?php dynField(@$country,'DO','option'); ?>>Dominican Republic</option>
 <option value="TP"<?php dynField(@$country,'TP','option'); ?>>East Timor</option>
 <option value="EC"<?php dynField(@$country,'EC','option'); ?>>Ecuador</option>
 <option value="EG"<?php dynField(@$country,'EG','option'); ?>>Egypt</option>
 <option value="SV"<?php dynField(@$country,'SV','option'); ?>>El Salvador</option>
 <option value="GQ"<?php dynField(@$country,'GQ','option'); ?>>Equatorial Guinea</option>
 <option value="ER"<?php dynField(@$country,'ER','option'); ?>>Eritrea</option>
 <option value="EE"<?php dynField(@$country,'EE','option'); ?>>Estonia</option>
 <option value="ET"<?php dynField(@$country,'ET','option'); ?>>Ethiopia</option>
 <option value="FK"<?php dynField(@$country,'FK','option'); ?>>Falkland Islands (Malvinas)</option>
 <option value="FO"<?php dynField(@$country,'FO','option'); ?>>Faroe Islands</option>
 <option value="FJ"<?php dynField(@$country,'FJ','option'); ?>>Fiji</option>
 <option value="FI"<?php dynField(@$country,'FI','option'); ?>>Finland</option>
 <option value="FR"<?php dynField(@$country,'FR','option'); ?>>France</option>
 <option value="FX"<?php dynField(@$country,'FX','option'); ?>>France, Metropolitan</option>
 <option value="GF"<?php dynField(@$country,'GF','option'); ?>>French Guiana</option>
 <option value="PF"<?php dynField(@$country,'PF','option'); ?>>French Polynesia</option>
 <option value="TF"<?php dynField(@$country,'TF','option'); ?>>French Southern Territories</option>
 <option value="GA"<?php dynField(@$country,'GA','option'); ?>>Gabon</option>
 <option value="GM"<?php dynField(@$country,'GM','option'); ?>>Gambia</option>
 <option value="GE"<?php dynField(@$country,'GE','option'); ?>>Georgia</option>
 <option value="DE"<?php dynField(@$country,'DE','option'); ?>>Germany</option>
 <option value="GH"<?php dynField(@$country,'GH','option'); ?>>Ghana</option>
 <option value="GI"<?php dynField(@$country,'GI','option'); ?>>Gibraltar</option>
 <option value="GR"<?php dynField(@$country,'GR','option'); ?>>Greece</option>
 <option value="GL"<?php dynField(@$country,'GL','option'); ?>>Greenland</option>
 <option value="GD"<?php dynField(@$country,'GD','option'); ?>>Grenada</option>
 <option value="GP"<?php dynField(@$country,'GP','option'); ?>>Guadeloupe</option>
 <option value="GU"<?php dynField(@$country,'GU','option'); ?>>Guam</option>
 <option value="GT"<?php dynField(@$country,'GT','option'); ?>>Guatemala</option>
 <option value="GN"<?php dynField(@$country,'GN','option'); ?>>Guinea</option>
 <option value="GW"<?php dynField(@$country,'GW','option'); ?>>Guinea-Bissau</option>
 <option value="GY"<?php dynField(@$country,'GY','option'); ?>>Guyana</option>
 <option value="HT"<?php dynField(@$country,'HT','option'); ?>>Haiti</option>
 <option value="HM"<?php dynField(@$country,'HM','option'); ?>>Heard and Mc Donald Islands</option>
 <option value="VA"<?php dynField(@$country,'VA','option'); ?>>Holy See (Vatican City State)</option>
 <option value="HN"<?php dynField(@$country,'HN','option'); ?>>Honduras</option>
 <option value="HK"<?php dynField(@$country,'HK','option'); ?>>Hong Kong</option>
 <option value="HU"<?php dynField(@$country,'HU','option'); ?>>Hungary</option>
 <option value="IS"<?php dynField(@$country,'IS','option'); ?>>Iceland</option>
 <option value="IN"<?php dynField(@$country,'IN','option'); ?>>India</option>
 <option value="ID"<?php dynField(@$country,'ID','option'); ?>>Indonesia</option>
 <option value="IR"<?php dynField(@$country,'IR','option'); ?>>Iran (Islamic Republic of)</option>
 <option value="IQ"<?php dynField(@$country,'IQ','option'); ?>>Iraq</option>
 <option value="IE"<?php dynField(@$country,'IE','option'); ?>>Ireland</option>
 <option value="IL"<?php dynField(@$country,'IL','option'); ?>>Israel</option>
 <option value="IT"<?php dynField(@$country,'IT','option'); ?>>Italy</option>
 <option value="JM"<?php dynField(@$country,'JM','option'); ?>>Jamaica</option>
 <option value="JP"<?php dynField(@$country,'JP','option'); ?>>Japan</option>
 <option value="JO"<?php dynField(@$country,'JO','option'); ?>>Jordan</option>
 <option value="KZ"<?php dynField(@$country,'KZ','option'); ?>>Kazakhstan</option>
 <option value="KE"<?php dynField(@$country,'KE','option'); ?>>Kenya</option>
 <option value="KI"<?php dynField(@$country,'KI','option'); ?>>Kiribati</option>
 <option value="KP"<?php dynField(@$country,'KP','option'); ?>>Korea, Democratic People's Republic of</option>
 <option value="KR"<?php dynField(@$country,'KR','option'); ?>>Korea, Republic of</option>
 <option value="KW"<?php dynField(@$country,'KW','option'); ?>>Kuwait</option>
 <option value="KG"<?php dynField(@$country,'KG','option'); ?>>Kyrgyzstan</option>
 <option value="LA"<?php dynField(@$country,'LA','option'); ?>>Lao People's Democratic Republic</option>
 <option value="LV"<?php dynField(@$country,'LV','option'); ?>>Latvia</option>
 <option value="LB"<?php dynField(@$country,'LB','option'); ?>>Lebanon</option>
 <option value="LS"<?php dynField(@$country,'LS','option'); ?>>Lesotho</option>
 <option value="LR"<?php dynField(@$country,'LR','option'); ?>>Liberia</option>
 <option value="LY"<?php dynField(@$country,'LY','option'); ?>>Libyan Arab Jamahiriya</option>
 <option value="LI"<?php dynField(@$country,'LI','option'); ?>>Liechtenstein</option>
 <option value="LT"<?php dynField(@$country,'LT','option'); ?>>Lithuania</option>
 <option value="LU"<?php dynField(@$country,'LU','option'); ?>>Luxembourg</option>
 <option value="MO"<?php dynField(@$country,'MO','option'); ?>>Macau</option>
 <option value="MK"<?php dynField(@$country,'MK','option'); ?>>Macedonia, The Former Yugoslav Republic of</option>
 <option value="MG"<?php dynField(@$country,'MG','option'); ?>>Madagascar</option>
 <option value="MW"<?php dynField(@$country,'MW','option'); ?>>Malawi</option>
 <option value="MY"<?php dynField(@$country,'MY','option'); ?>>Malaysia</option>
 <option value="MV"<?php dynField(@$country,'MV','option'); ?>>Maldives</option>
 <option value="ML"<?php dynField(@$country,'ML','option'); ?>>Mali</option>
 <option value="MT"<?php dynField(@$country,'MT','option'); ?>>Malta</option>
 <option value="MH"<?php dynField(@$country,'MH','option'); ?>>Marshall Islands</option>
 <option value="MQ"<?php dynField(@$country,'MQ','option'); ?>>Martinique</option>
 <option value="MR"<?php dynField(@$country,'MR','option'); ?>>Mauritania</option>
 <option value="MU"<?php dynField(@$country,'MU','option'); ?>>Mauritius</option>
 <option value="YT"<?php dynField(@$country,'YT','option'); ?>>Mayotte</option>
 <option value="MX"<?php dynField(@$country,'MX','option'); ?>>Mexico</option>
 <option value="FM"<?php dynField(@$country,'FM','option'); ?>>Micronesia, Federated States of</option>
 <option value="MD"<?php dynField(@$country,'MD','option'); ?>>Moldova, Republic of</option>
 <option value="MC"<?php dynField(@$country,'MC','option'); ?>>Monaco</option>
 <option value="MN"<?php dynField(@$country,'MN','option'); ?>>Mongolia</option>
 <option value="MS"<?php dynField(@$country,'MS','option'); ?>>Montserrat</option>
 <option value="MA"<?php dynField(@$country,'MA','option'); ?>>Morocco</option>
 <option value="MZ"<?php dynField(@$country,'MZ','option'); ?>>Mozambique</option>
 <option value="MM"<?php dynField(@$country,'MM','option'); ?>>Myanmar</option>
 <option value="NA"<?php dynField(@$country,'NA','option'); ?>>Namibia</option>
 <option value="NR"<?php dynField(@$country,'NR','option'); ?>>Nauru</option>
 <option value="NP"<?php dynField(@$country,'NP','option'); ?>>Nepal</option>
 <option value="NL"<?php dynField(@$country,'NL','option'); ?>>Netherlands</option>
 <option value="AN"<?php dynField(@$country,'AN','option'); ?>>Netherlands Antilles</option>
 <option value="NC"<?php dynField(@$country,'NC','option'); ?>>New Caledonia</option>
 <option value="NZ"<?php dynField(@$country,'NZ','option'); ?>>New Zealand</option>
 <option value="NI"<?php dynField(@$country,'NI','option'); ?>>Nicaragua</option>
 <option value="NE"<?php dynField(@$country,'NE','option'); ?>>Niger</option>
 <option value="NG"<?php dynField(@$country,'NG','option'); ?>>Nigeria</option>
 <option value="NU"<?php dynField(@$country,'NU','option'); ?>>Niue</option>
 <option value="NF"<?php dynField(@$country,'NF','option'); ?>>Norfolk Island</option>
 <option value="MP"<?php dynField(@$country,'MP','option'); ?>>Northern Mariana Islands</option>
 <option value="NO"<?php dynField(@$country,'NO','option'); ?>>Norway</option>
 <option value="OM"<?php dynField(@$country,'OM','option'); ?>>Oman</option>
 <option value="PK"<?php dynField(@$country,'PK','option'); ?>>Pakistan</option>
 <option value="PW"<?php dynField(@$country,'PW','option'); ?>>Palau</option>
 <option value="PA"<?php dynField(@$country,'PA','option'); ?>>Panama</option>
 <option value="PG"<?php dynField(@$country,'PG','option'); ?>>Papua New Guinea</option>
 <option value="PY"<?php dynField(@$country,'PY','option'); ?>>Paraguay</option>
 <option value="PE"<?php dynField(@$country,'PE','option'); ?>>Peru</option>
 <option value="PH"<?php dynField(@$country,'PH','option'); ?>>Philippines</option>
 <option value="PN"<?php dynField(@$country,'PN','option'); ?>>Pitcairn</option>
 <option value="PL"<?php dynField(@$country,'PL','option'); ?>>Poland</option>
 <option value="PT"<?php dynField(@$country,'PT','option'); ?>>Portugal</option>
 <option value="PR"<?php dynField(@$country,'PR','option'); ?>>Puerto Rico</option>
 <option value="QA"<?php dynField(@$country,'QA','option'); ?>>Qatar</option>
 <option value="RE"<?php dynField(@$country,'RE','option'); ?>>Reunion</option>
 <option value="RO"<?php dynField(@$country,'RO','option'); ?>>Romania</option>
 <option value="RU"<?php dynField(@$country,'RU','option'); ?>>Russian Federation</option>
 <option value="RW"<?php dynField(@$country,'RW','option'); ?>>Rwanda</option>
 <option value="KN"<?php dynField(@$country,'KN','option'); ?>>Saint Kitts and Nevis</option>
 <option value="LC"<?php dynField(@$country,'LC','option'); ?>>Saint LUCIA</option>
 <option value="VC"<?php dynField(@$country,'VC','option'); ?>>Saint Vincent and the Grenadines</option>
 <option value="WS"<?php dynField(@$country,'WS','option'); ?>>Samoa</option>
 <option value="SM"<?php dynField(@$country,'SM','option'); ?>>San Marino</option>
 <option value="ST"<?php dynField(@$country,'ST','option'); ?>>Sao Tome and Principe</option>
 <option value="SA"<?php dynField(@$country,'SA','option'); ?>>Saudi Arabia</option>
 <option value="SN"<?php dynField(@$country,'SN','option'); ?>>Senegal</option>
 <option value="SC"<?php dynField(@$country,'SC','option'); ?>>Seychelles</option>
 <option value="SL"<?php dynField(@$country,'SL','option'); ?>>Sierra Leone</option>
 <option value="SG"<?php dynField(@$country,'SG','option'); ?>>Singapore</option>
 <option value="SK"<?php dynField(@$country,'SK','option'); ?>>Slovakia (Slovak Republic)</option>
 <option value="SI"<?php dynField(@$country,'SI','option'); ?>>Slovenia</option>
 <option value="SB"<?php dynField(@$country,'SB','option'); ?>>Solomon Islands</option>
 <option value="SO"<?php dynField(@$country,'SO','option'); ?>>Somalia</option>
 <option value="ZA"<?php dynField(@$country,'ZA','option'); ?>>South Africa</option>
 <option value="GS"<?php dynField(@$country,'GS','option'); ?>>South Georgia and the South Sandwich Islands</option>
 <option value="ES"<?php dynField(@$country,'ES','option'); ?>>Spain</option>
 <option value="LK"<?php dynField(@$country,'LK','option'); ?>>Sri Lanka</option>
 <option value="SH"<?php dynField(@$country,'SH','option'); ?>>St. Helena</option>
 <option value="PM"<?php dynField(@$country,'PM','option'); ?>>St. Pierre and Miquelon</option>
 <option value="SD"<?php dynField(@$country,'SD','option'); ?>>Sudan</option>
 <option value="SR"<?php dynField(@$country,'SR','option'); ?>>Suriname</option>
 <option value="SJ"<?php dynField(@$country,'SJ','option'); ?>>Svalbard and Jan Mayen Islands</option>
 <option value="SZ"<?php dynField(@$country,'SZ','option'); ?>>Swaziland</option>
 <option value="SE"<?php dynField(@$country,'SE','option'); ?>>Sweden</option>
 <option value="CH"<?php dynField(@$country,'CH','option'); ?>>Switzerland</option>
 <option value="SY"<?php dynField(@$country,'SY','option'); ?>>Syrian Arab Republic</option>
 <option value="TW"<?php dynField(@$country,'TW','option'); ?>>Taiwan, Province of China</option>
 <option value="TJ"<?php dynField(@$country,'TJ','option'); ?>>Tajikistan</option>
 <option value="TZ"<?php dynField(@$country,'TZ','option'); ?>>Tanzania, United Republic of</option>
 <option value="TH"<?php dynField(@$country,'TH','option'); ?>>Thailand</option>
 <option value="TG"<?php dynField(@$country,'TG','option'); ?>>Togo</option>
 <option value="TK"<?php dynField(@$country,'TK','option'); ?>>Tokelau</option>
 <option value="TO"<?php dynField(@$country,'TO','option'); ?>>Tonga</option>
 <option value="TT"<?php dynField(@$country,'TT','option'); ?>>Trinidad and Tobago</option>
 <option value="TN"<?php dynField(@$country,'TN','option'); ?>>Tunisia</option>
 <option value="TR"<?php dynField(@$country,'TR','option'); ?>>Turkey</option>
 <option value="TM"<?php dynField(@$country,'TM','option'); ?>>Turkmenistan</option>
 <option value="TC"<?php dynField(@$country,'TC','option'); ?>>Turks and Caicos Islands</option>
 <option value="TV"<?php dynField(@$country,'TV','option'); ?>>Tuvalu</option>
 <option value="UG"<?php dynField(@$country,'UG','option'); ?>>Uganda</option>
 <option value="UA"<?php dynField(@$country,'UA','option'); ?>>Ukraine</option>
 <option value="AE"<?php dynField(@$country,'AE','option'); ?>>United Arab Emirates</option>
 <option value="GB"<?php dynField(@$country,'GB','option'); ?>>United Kingdom</option>
 <option value="US"<?php dynField(@$country,'US','option'); ?>>United States</option>
 <option value="UM"<?php dynField(@$country,'UM','option'); ?>>United States Minor Outlying Islands</option>
 <option value="UY"<?php dynField(@$country,'UY','option'); ?>>Uruguay</option>
 <option value="UZ"<?php dynField(@$country,'UZ','option'); ?>>Uzbekistan</option>
 <option value="VU"<?php dynField(@$country,'VU','option'); ?>>Vanuatu</option>
 <option value="VE"<?php dynField(@$country,'VE','option'); ?>>Venezuela</option>
 <option value="VN"<?php dynField(@$country,'VN','option'); ?>>Viet Nam</option>
 <option value="VG"<?php dynField(@$country,'VG','option'); ?>>Virgin Islands (British)</option>
 <option value="VI"<?php dynField(@$country,'VI','option'); ?>>Virgin Islands (U.S.)</option>
 <option value="WF"<?php dynField(@$country,'WF','option'); ?>>Wallis and Futuna Islands</option>
 <option value="EH"<?php dynField(@$country,'EH','option'); ?>>Western Sahara</option>
 <option value="YE"<?php dynField(@$country,'YE','option'); ?>>Yemen</option>
 <option value="YU"<?php dynField(@$country,'YU','option'); ?>>Yugoslavia</option>
 <option value="ZM"<?php dynField(@$country,'ZM','option'); ?>>Zambia</option>
 <option value="ZW"<?php dynField(@$country,'ZW','option'); ?>>Zimbabwe</option>
</select>

Google Maps Static Images, How to Create

March 30th, 2010

Creating Google maps images to display on your website are really neat. They load really fast and can really give visitors a good idea of where something is located. I personally like to use them on contact us pages to show the location of a company.

Creating them is a blast and relatively easy. First you will need to know the location of the company or whatever your looking to create a map for. Next have an idea of what type of dimensions you want the map to be and finally if you want markers on it you will need to know the latitude and longitude of the spot the market should go.

After you’ve compiled all that data together now is the easy part, just replace your data with what is in the below URL.

http://maps.google.com/staticmap?size=300x115&center=mars+pa&zoom=13&markers=40.6958996,-80.0117254
&key=YOUR_KEY_HERE

This gives you:

You will also notice there is a zoom reference in the URL above. With that you can set how close or far out the zoom level is for the screen shot of the map.

If you are clueless and scratching your head when you look at this URL and don’t get how to put the data in, here are some helpful hints. Directly after each & symbol in the URL is what is called a parameter. This basically is a “label” that you can define. For example in URL above you will see “size” this is a parameter that we can set, simple add your dimensions after the equals sign (make sure you keep the same format).

So now you have a basic understanding of the syntax of the URL you might be wondering what the parameter “center” is for… well that’s the address for the company or place you want a map of. And of course “marker” is the latitude and longitude of where the marker should fall on the map. Also make sure to replace the YOUR_KEY_HERE with the key get from signing up with Google Maps API.

Lastly take the URL and put it into an image’s source tag as follows:

<img src="http://maps.google.com/staticmap?size=300x115&center=mars+pa&zoom=13&markers=40.6958996,
-80.0117254&key=YOUR_KEY_HERE" alt=""/>

I’ve also found a good reference for creating these maps really quickly if you’re still having trouble, can’t calculate the lat and long for the market, or just want something faster/easier then try Google Static Map Wizard.

FLV File not working on WebHost4Life.com, How to fix

March 10th, 2010

I recently was working on a website containing some flash for a client and we noticed that flash files referencing external FLV documents on the server were not loading. Well at first I thought it must be something within the flash piece that was wrong. But after several tries and rewrites of the code I decided to test the flash piece by using the publish test in my version of Adobe Flash (AS3). Upon testing I got a output message that the FLV file could not be opened.

Well I thought that was interesting as I know it’s uploaded to the server. So I tried browsing for the file via my favorite Internet browser and what-do-you-know I got a 404 error. Obviously I checked again to make sure the FLV file was on the server but yet again I found it was. So my next thought was well maybe this hosting provider has some sort of issue with FLV files.

Therefore I did a little Google search and yep, WebHost4Life.com has some issues with loading FLV files. They don’t recognize Mime Type FLV on their IIS servers (Windows servers) by default. So what’s the solution..?, well luckily you can add in another Mime Type right from your hosting control panel.

Here are the steps to get the FLV files working on WebHost4Life.com:

  1. Login
  2. Select “Site Admin” from the horizontal menu
  3. Select “Set MIME Type” from the vertical submenu
  4. From the list of websites (if you have a list) select “Go” for the website you want to add the MIME type too.
  5. Type in the following to support the .flv MIME type:
    MIME TYPE: video/x-flv
    EXTENSION: flv (without the period “.”)

(Credit to Herb Benton from bizmodules.net for figuring that out.)

Make IE8 Emulate IE7

December 18th, 2009

For those of you finding IE8 to be another Microsoft beast to tame just as IE6 as been, I’ve provided a solution I found from Microsoft that will make IE8 emulate IE7 or to more accurately put it with render as if IE7. Although do be aware according to Microsoft, this makes Internet Explorer 8 render as if IE7 but still accesses what IE8 has to offer therefore there may be some differences in what you see compared to the stand alone IE7.

Place the following code into your header to make IE8 render as if IE7.

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>

This code will not only handle layout issues but also some JavaScript issues.

Why do we have these issues?
As Microsoft states: “These issues may occur because Internet Explorer 8 displays webpages using “Standards mode” by default, whereas most current webpages are created and tested to work with Internet Explorer 7 Standards mode.”

Read the full text from Microsoft on the issue:
Update your site to render in IE7 Mode
And yet more information on this issue, specifically going over using the code above.
Internet Explorer Compatibility, X-UA-Compatible Tag and More for Developers

How To Turn on Compatibility Mode
If you’re looking for how to make enable the compatibility view your self instead of from within the webpage’s code then here is the “how to” from Microsoft. Some Web sites may not be displayed correctly or work correctly in Windows Internet Explorer 8

PHP Email Yahoo Hosting, How To

December 4th, 2009

In this tutorial I’m going to show you how to setup a PHP email form with Yahoo hosting. One of the things I’ve found with Yahoo hosting and using PHP to send emails is that there are quite a few steps you have to go through in order to get it working. But lucky you, I’ve figured it all out and laid out the steps below.

Also you should note that Yahoo has a max limit on the number of emails that can be sent, only 250 emails every 24 hours to recipients that are outside any emails not associated with your domain name (IE: emails that don’t go to name@yourwebsite.com). And you can only set the email’s “from address” as an email at your domain name (example: name@yourdomain.com).

Here are the things you will need to complete this tutorial:

  1. Yahoo web hosting login details (username and password).
  2. From email address set up at the same domain name as your emailing from.

How to Send PHP Email with Yahoo Hosting:

  1. Sign in to Yahoo web hosting “Small Business”. You’ll need to click on the Small Business and then login there.
  2. Next click on the Create & Upload tab.
  3. Now scroll down to the “Other Site Building Tools” section. Sometimes this section will be closed and you will not see it’s contents. You need to click on the arrow to open it’s contents and then click on the PHP/Perl Mail link within this section’s content.
  4. On the next page under the “PHP/Perl Mail Setup” section on the right hand column enter in your email address you would like the form to send to. Then click the “Set Default” button.
  5. Now you can use the PHP mail() function to send email but you will have to use the from address as the one you set in the above step. The PHP mail() function is a function that sends emails using PHP coding. Here is an example of it’s usage.
    <?php
    $to = 'Your_Email_Here@Your_Domain.com';
    $subject = 'Subject_Goes_Here';
    $headers = 'FROM: <Your_Email_Here@Your_Domain.com>';
    mail($to, $subject, $message, $headers);
    ?>

    For more on the PHP mail() function visit the PHP manual, PHP: mail – Manual

Useful Related links:
Yahoo’s tutorial on how to send email using php: How can I send email with PHP?