A Pen by Michael Ryan Soileau on CodePen.
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 | |
/** | |
* @file | |
* Sets up debugging tools, if enabled. | |
* PHP Debug is very powerful, but you have to configure numerous files to get it to work. | |
*/ | |
// Enable or disable debugging tools. | |
$tools = array( | |
'chromephp' => FALSE, |
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 | |
$errors = array(); | |
function fieldname_as_text($fieldname) { | |
$fieldname = str_replace("_", " ", $fieldname); | |
$fieldname = ucfirst($fieldname); | |
return $fieldname; | |
} |
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 | |
function redirect_to($new_location) { | |
header("Location: " . $new_location); | |
exit; | |
} | |
// This function will sanitize a string. Requires a connection. | |
function mysql_prep($string) { |
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 | |
try { | |
$db = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME .";port=" . DB_PORT,DB_USER,DB_PASS); | |
$db->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); | |
$db->exec("SET NAMES 'utf8'"); | |
} catch (Exception $e) { | |
echo "Could not connect to the database."; | |
exit; | |
} |
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 set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); ?> | |
<?php /* Another way of handling the same problem */ | |
$path = $_SERVER['DOCUMENT_ROOT']; | |
$path .= "/common/header.php"; | |
include_once($path); | |
dirname(__FILE__); |
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 | |
// if the value passed into the GET should be an int. | |
$intStorage = intval($_GET['someValue']); | |
// Using PDO | |
$db = new PDO(); | |
$query = $db->prepare("SELECT someRow FROM table WHERE value = ?"); | |
$query->bindParam(1,$bindedValue); | |
// The first argument is number of prepared statements, second is the value. | |
$query->execute(); | |
// Boolean false if nothing is found. |
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
$sql_value = "SELECT DISTINCT siteID FROM users WHERE entityID = $someVariable GROUP BY siteID;"; | |
$sql_res = mysqli_query($dropdown_connect, $sql_value) or die(mysqli_error($dropdown_connect)); | |
while ($row_info = mysqli_fetch_array($sql_res)) { | |
echo "<option value='$row_info[0] . '>" . $row_info[0] . "<style='width:200px;'></option>"; | |
} // End while loop |
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 | |
$headers = apache_request_headers(); | |
foreach ($headers as $header => $value) { | |
echo "$header: $value <br />\n"; | |
} | |
$headers_response = apache_response_headers(); |
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 | |
define("DS",DIRECTORY_SEPARATOR,true); | |
define('BASE_PATH',realpath(dirname(__FILE__)).DS,true); | |
$include_file = BASE_PATH . '.mysql.inc.php'; | |
?> |
OlderNewer