This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Database Constants | |
define("DB_SERVER", "127.0.0.1"); | |
define("DB_USER", "root"); | |
define("DB_PASS", "happy"); | |
define("DB_NAME", "folio"); | |
// 1. Create a database connection | |
$connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS); | |
if ( !$connection ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source: http://stackoverflow.com/questions/129677/whats-the-best-method-for-sanitizing-user-input-with-php | |
also see: http://net.tutsplus.com/tutorials/php/sanitize-and-validate-data-with-php-filters/ | |
"It's a common misconception that user input can be filtered. PHP even has a (now deprecated) "feature", called magic-quotes, that builds on this idea. It's nonsense. Forget about filtering (Or cleaning, or whatever people call it). | |
What you should do, to avoid problems is quite simple: Whenever you embed a string within foreign code, you must escape it, according to the rules of that language. For example, if you embed a string in some SQL targeting MySql, you must escape the string with MySql's function for this purpose (mysql_real_escape_string). | |
Another example is HTML; If you embed strings within HTML markup, you must escape it with htmlspecialchars. This means that every single echo or print statement should use htmlspecialchars. | |
A third example could be shell commands; If you are going to embed strings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<!-- from JQuery API --> | |
<html> | |
<head> | |
<style> | |
div { color:blue; } | |
span { color:red; } | |
b { font-weight:bolder; } | |
</style> | |
<script src="http://code.jquery.com/jquery-latest.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//"Custom data attributes are intended to store custom data private to the page or application, | |
// for which there are no more appropriate attributes or elements." | |
// - dev.w3.org/html5/spec/elements.html#embedding-custom-non-visible-data-with-the-data-attributes | |
//Examples below: | |
<div data-type="sprite" data-offsetY="100" data-Xposition="50%" data-speed="2"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Thing(name) { | |
this.name = name; | |
} | |
Thing.prototype.doSomething = function(callback) { | |
// Call our callback, but using our own instance as the context | |
callback.apply(this, ['Hi', 3, 2, 1]); | |
} | |
function foo(salutation, three, two, one) { | |
alert(salutation + " " + this.name + " - " + three + " " + two + " " + one); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mySandwich(param1, param2, callback) { | |
alert('Started eating my sandwich.\n\nIt has: ' + param1 + ', ' + param2); | |
if (callback && typeof(callback) === "function") { | |
callback(); | |
} | |
} | |
mySandwich('ham', 'cheese', 'vegetables'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---------------------------------------------------------------------------- | |
// HasClassName | |
// credit: dzone.com | |
// Description : returns boolean indicating whether the object has the class name | |
// built with the understanding that there may be multiple classes | |
// | |
// Arguments: | |
// objElement - element to manipulate | |
// strClass - class name to add | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Menu Navigator</title> | |
<link rel="stylesheet" href="style.css"> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | |
<script src='script.js'></script> | |
</head> | |
<body> | |
<div class="tabbed-menu"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#panel { | |
padding: 50px; | |
height: 100px; | |
width: 500px; | |
text-align: center; | |
font-size: 24px; | |
font-family: Arial; | |
font-weight: bold; | |
background: #EEE; | |
cursor: pointer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Sliders!</title> | |
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/themes/base/jquery-ui.css"/> | |
<link rel="stylesheet" href="style.css"/> | |
</head> | |
<body> | |
<div id="tabs"> | |
<ul> | |
<li><a href="#tabs-1">Nunc tincidunt</a></li> |
NewerOlder