I am in the process of writing a demo which shows source files and requires database access.
I managed to solve the problem of not publishing my database login details but convince there must be a better way.
// Database Access Details
$docRoot = $_SERVER['DOCUMENT_ROOT'];
$lastPath = strrchr($docRoot, '/');
$aboveRoot = str_replace($lastPath, '/', $docRoot);
$aboveRoot .= '_dbPARAMS.php';
if( file_exists($aboveRoot) ):
require $aboveRoot;
else:
define('HOST', 'yourhost');
define('uName', 'userName');
define('pWORD', 'passWord');
define('dBase', 'dataBase');
define('dTABLE', 'tableName');
define('dCOLUMN','columnName'); // SEE KLUDGE BELOW
endif;
$conn = mysqli_connect(HOST, uNAME, pWORD, dBASE);
$sql = 'SELECT * FROM ' .dTABLE .' WHERE ';// .dCOLUMN;
foreach($aParams as $i2 => $param):
if($i2 > 0):
$sql = $sql .' AND ';
endif;
$sql = $sql .dCOLUMN .' LIKE "%'. trim($param) .'%" ';
endforeach;
// all the constants work except dCOLUMN
$dCOLUMN = dCOLUMN; // KLUDGE constant to string!!!
while($row = mysqli_fetch_array($result))
{
echo '<br />' . $row["$dCOLUMN"];// see KLUDGE above
}