Tuesday, November 22, 2011

Firefox is working but Chrome and IE aren’t


This is a proxy error usually caused by a virus.
Load internet explorer then on the Tools menu in Internet Explorer, click Internet Options, click the Connections tab, and then click LAN Settings. Then there will be two check boxes that are checked. First uncheck the second/bottom box then the first/top box. Then Click OK. Then Both will be fixed as Chrome uses IE configs.

Display state name from 2 letter state php script


<?php
$state = array();
  $state['AL']='ALABAMA';
  $state['AL']='ALASKA';
  $state['AS']='AMERICAN SAMOA';
  $state['AZ']='ARIZONA';
  $state['AR']='ARKANSAS';
  $state['CA']='CALIFORNIA';
  $state['CO']='COLORADO';
  $state['CT']='CONNECTICUT';
  $state['DE']='DELAWARE';
  $state['DC']='DISTRICT OF COLUMBIA';
  $state['FM']='FEDERATED STATES OF MICRONESIA';
  $state['FL']='FLORIDA';
  $state['GA']='GEORGIA';
  $state['GU']='GUAM';
  $state['HI']='HAWAII';
  $state['ID']='IDAHO';
  $state['IL']='ILLINOIS';
  $state['IN']='INDIANA';
  $state['IA']='IOWA';
  $state['KS']='KANSAS';
  $state['KY']='KENTUCKY';
  $state['LA']='LOUISIANA';
  $state['ME']='MAINE';
  $state['MH']='MARSHALL ISLANDS';
  $state['MD']='MARYLAND';
  $state['MA']='MASSACHUSETTS';
  $state['MI']='MICHIGAN';
  $state['MN']='MINNESOTA';
  $state['MS']='MISSISSIPPI';
  $state['MO']='MISSOURI';
  $state['MT']='MONTANA';
  $state['NE']='NEBRASKA';
  $state['NV']='NEVADA';
  $state['NH']='NEW HAMPSHIRE';
  $state['NJ']='NEW JERSEY';
  $state['NM']='NEW MEXICO';
  $state['NY']='NEW YORK';
  $state['NC']='NORTH CAROLINA';
  $state['ND']='NORTH DAKOTA';
  $state['MP']='NORTHERN MARIANA ISLANDS';
  $state['OH']='OHIO';
  $state['OK']='OKLAHOMA';
  $state['OR']='OREGON';
  $state['PW']='PALAU';
  $state['PA']='PENNSYLVANIA';
  $state['PR']='PUERTO RICO';
  $state['RI']='RHODE ISLAND';
  $state['SC']='SOUTH CAROLINA';
  $state['SD']='SOUTH DAKOTA';
  $state['TN']='TENNESSEE';
  $state['TX']='TEXAS';
  $state['UT']='UTAH';
  $state['VT']='VERMONT';
  $state['VI']='VIRGIN ISLANDS';
  $state['VA']='VIRGINIA';
  $state['WA']='WASHINGTON';
  $state['wv']='WEST VIRGINIA';
  $state['WI']='WISCONSIN';
  $state['WY']='WYOMING';
  //canadian provinces
  $state['AB']='ALBERTA';
  $state['BC']='BRITISH COLUMBIA';
  $state['MB']='MANITOBA';
  $state['NB']='NEW BRUNSWICK';
  $state['NL']='LABRADOR';
  $state['NL']='NEWFOUNDLAND';
  $state['NT']='NORTHWEST TERRITORIES';
  $state['NS']='NOVA SCOTIA';
  $state['NU']='NUNAVUT';
  $state['ON']='ONTARIO';
  $state['PE']='PRINCE EDWARD ISLAND';
  $state['QC']='QUEBEC';
  $state['SK']='SASKATCHEWAN';
  $state['YT']='YUKON';
                $sc = 'CA'; //change CA to the variable
                $statez = $state[''.$sc.'']; //can do strtolower on statez if need be
?>

Thursday, November 17, 2011

Get twitter status using PHP



<?
echo get_status('username');


function get_status($twitter_id, $hyperlinks = true) {
    $c = curl_init();
    curl_setopt($c, CURLOPT_URL, \"http://twitter.com/statuses/user_timeline/$twitter_id.xml?count=1\");
    curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
    $src = curl_exec($c);
    curl_close($c);
    preg_match(\'/<text>(.*)<\\/text>/\', $src, $m);
    $status = htmlentities($m[1]);
    if( $hyperlinks ) $status = ereg_replace(\"[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]\", \'<a href=\"%5C%22%5C%5C0%5C%22\">\\\\0</a>\', $status);
    return($status);
}
?>

Thursday, November 3, 2011

What is Main Difference between PHP4 and PHP5?


You most likely know that PHP 5 is destined for OOP, but it appears that usual programming can be used too. Furthermore, OOP is used in PHP4 as well, with the difference that in PHP5 things are a little more evaluated. This means that in PHP4 safety modes for classes (public, private) are not accepted. In PHP4 the objects are a kind of structures which accept objects and functions as well, according to OOP. In PHP4 they are useful as well.
If you are used to working with PHP4 you can use PHP5 with no problems because the differences are not important and the changes were made so that programmers would not be confused. An example would be class builders which, in PHP4 were functions within the classes bearing the same name as the class. In PHP5 it is firstly checked if there is a function (method) __construct (). If it does not exist, check if there is a function (method) which has the same name as the class. This means that even if you are not aware of the latest news in the domain of PHP5, your scripts will function without any problem.

PHP 5.4 beta2 released

The PHP development team is proud to announce the second beta release of PHP 5.4. PHP 5.4 includes new language features and removes several legacy (deprecated) behaviours. Windows binaries can be downloaded from the Windows QA site. THIS IS A DEVELOPMENT PREVIEW - DO NOT USE IT IN PRODUCTION! Please help us to identify bugs by testing new features and looking for unintended backward compatibility breaks, so we can fix the problems and fully document intended changes before PHP 5.4.0 is released. Report findings to the QA mailing list and/or the PHP bug tracker. This release includes numerous bug fixes and improvements since the first beta release. Read the NEWS file for a complete list of changes.

Enable Textbox after selecting the checkbox

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="javascript">
function enableMe(fld)
{
eval('window.document.formx.'+fld+'.disabled = !window.document.formx.'+fld+'CB'+'.checked');
}
</script>
</head>
<body>
<form name="formx" action="" method="post" >
  <table>
    <tr>
      <td><input type="text" disabled="disabled" name="firstbox" value="First box" >
      </td>
      <td width="235"><input type="checkbox" value="1" name="firstboxCB" onClick="enableMe('firstbox');" />
      </td>
    </tr>
    <tr>
      <td><input type="text" disabled="disabled" name="secondbox" value="Second box" >
      </td>
      <td width="235"><input type="checkbox" value="1" name="secondboxCB" onClick="enableMe('secondbox');" />
      </td>
    </tr>
  </table>
</form>
</body>
</html>

Preview:



Using Radio buttons Display specified number of file uploads

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
function show_up(x){


  if(x > 5){
     document.getElementById('extra').style.display = 'table-cell';
document.getElementById('extras').style.display = 'none';

  }else{
     document.getElementById('extras').style.display = 'table-cell';
document.getElementById('extra').style.display = 'none';

  }

}
</script>
<style>
  .hide{
     display:none;
  }
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form name="form" method="post">
  <input name="showups" type="radio" value="0" onclick="show_up(5);"/>
  <label for="show5">Show 5 upload fields</label>
  <input name="showups" id="show10" type="radio" value="1" onclick="show_up(10);"/>
  <label for="show10">Show 10 upload fields</label>
  <div id = "extra" class="show" style="display:none">
    <table>
      <tr>
        <td><input type="file" name="upload[]" />
        </td>
      </tr>
      <tr>
        <td><input type="file" name="upload[]" />
        </td>
      </tr>
      <tr>
        <td><input type="file" name="upload[]" />
        </td>
      </tr>
      <tr>
        <td><input type="file" name="upload[]" />
        </td>
      </tr>
      <tr>
        <td><input type="file" name="upload[]" />
        </td>
      </tr>
      <tr>
        <td><input type="file" name="upload[]" />
        </td>
      </tr>
      <tr>
        <td><input type="file" name="upload[]" />
        </td>
      </tr>
      <tr>
        <td><input type="file" name="upload[]" />
        </td>
      </tr>
      <tr>
        <td><input type="file" name="upload[]" />
        </td>
      </tr>
      <tr>
        <td><input type="file" name="upload[]" />
        </td>
      </tr>
    </table>
  </div>
  <div id = "extras" class="show" style="display:none">
    <table>
      <tr>
        <td><input type="file" name="upload[]" />
        </td>
      </tr>
      <tr>
        <td><input type="file" name="upload[]" />
        </td>
      </tr>
      <tr>
        <td><input type="file" name="upload[]" />
        </td>
      </tr>
      <tr>
        <td><input type="file" name="upload[]" />
        </td>
      </tr>
      <tr>
        <td><input type="file" name="upload[]" />
        </td>
      </tr>
    </table>
  </div>
</form>
</body>
</html>



Preview: