nox.freak  [ Profile ]

Classer par : Date / Titre /

  1. il y a 1 an
    This will get the last entry into a database where COL is equal to something.
    1. SELECT * FROM TABLE WHERE COL=something ORDER BY id DESC LIMIT 0,1
    Copier ceci sur votre site: <script type="text/javascript" src="http://www.posteet.com/embed/1289"></script>
  2. il y a 1 an
    Takes a birth date and will spit out how old that person is.
    1. function getAge($date)
    2. {
    3.         list($y,$m,$d) = explode("-", $date);
    4.         $age = date("Y") - $y;
    5.         if( date("md") < $m.$d )
    6.         {
    7.                 $age--;
    8.         }
    9.         return $age;
    10. }
    Copier ceci sur votre site: <script type="text/javascript" src="http://www.posteet.com/embed/1288"></script>
  3. il y a 1 an
    This is just a basic way to query a MySQL database.
    1. define("DBNAME", "db_name");
    2. define("HOST", "localhost");
    3. define("USER", "foo");
    4. define("PASSWORD", "bar");
    5.  
    6. $dbconnect = mysql_connect(HOST, USER, PASSWORD);
    7. mysql_select_db(DBNAME, $dbconnect);
    8.  
    9. $sql = 'SELECT * FROM table';
    10. $q = mysql_query($sql, $dbconnect) or die("Error: " . mysql_error());
    11. $num = mysql_num_rows($q);
    12. for ($i=0; $i<$num; $i++)
    13. {
    14.         $dbOut = mysql_fetch_assoc($q);
    15.         echo $dbOut['col'];
    16. }
    Copier ceci sur votre site: <script type="text/javascript" src="http://www.posteet.com/embed/1287"></script>
  4. sponsorised links
  5. il y a 1 an
    Handles response from an ajax request.
    1. function ajaxRequest()
    2. {
    3.         var opt = 's=whatever you want to pass';
    4.         var page = 'ajax_page.php';
    5.  
    6.         var http = createRequestObject();
    7.         http.onreadystatechange = function()
    8.         {
    9.                 if((http.readyState == 4) && (http.status == 200))
    10.                 {
    11.                         var text = http.responseText;
    12.                 }
    13.         }
    14.         http.open('POST', page, true);
    15.         http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    16.         http.setRequestHeader("Content-length", opt.length);
    17.         http.setRequestHeader("Connection", "close");
    18.         http.send(opt);
    19. }
    Copier ceci sur votre site: <script type="text/javascript" src="http://www.posteet.com/embed/1286"></script>
  6. il y a 1 an
    Checks to see if browser is IE based or other.
    1. function createRequestObject(handler)
    2. {
    3.         var xmlHttp;
    4.         try
    5.         {
    6.                 // Firefox, Opera 8.0+, Safari
    7.                 var xmlHttp = new XMLHttpRequest();
    8.                 xmlHttp.onload=handler;
    9.                 xmlHttp.onerror=handler;
    10.                 return xmlHttp;
    11.         }
    12.         catch (e)
    13.         {
    14.                 // Internet Explorer
    15.                 try
    16.                 {
    17.                         xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    18.                         return xmlHttp;
    19.                 }
    20.                 catch (e)
    21.                 {
    22.                         try
    23.                         {
    24.                                 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    25.                                 return xmlHttp;
    26.                         }
    27.                         catch (e)
    28.                         {
    29.                                 alert("Your browser does not support AJAX!");
    30.                                 return false;
    31.                         }
    32.                 }
    33.         }
    34. }
    Copier ceci sur votre site: <script type="text/javascript" src="http://www.posteet.com/embed/1285"></script>
  7. il y a 1 an
    Checks emails format, unlike others it supports have a plus (+) sign in the address. NOTE: this is easy for the user to by pass, as it is in javascript witch is not server side code.
    1. function emlChk(str) // email format checker/validator.
    2. {
    3.         var filter='^((?:(\\")|\.|\+|\!|\$|&|\*|\-|\=|\^|\`|\||\~|\#|\%|'|\/|\?|\_|\{|\}|\s|\@|\w)*)@(?:[\w-]+\.){1,255}(ac|ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|asia|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cat|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|info|int|io|iq|ir|is|it|je|jm|jo|jobs|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mil|mk|ml|mm|mn|mo|mobi|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|travel|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|xn|ye|yt|yu|za|zm|zw)$'
    4.         if(filter.test(str))
    5.         {
    6.                 return true
    7.         } else {
    8.                 return false
    9.         }
    10. }
    Copier ceci sur votre site: <script type="text/javascript" src="http://www.posteet.com/embed/1284"></script>

Première / Précédent / Suivant / Dernière / Page 1 sur 1 (6 posteets)