function array_map_callback($a)
{
return mysqli_real_escape_string($GLOBALS['mysqli'], $a);
}
function DBQuery($query, $debug = 0) {
$data = array();
if($result = $GLOBALS['mysqli']->query($query)){
return $result;
} else {
$final['error'] = "Database error.";
if($debug){
$final['debug'] = $debug;
$final['query'] = trim(preg_replace('/\s\s+/', ' ', $query));
$final['mysql_error'] = $GLOBALS['mysqli']->error;
}
echo json_encode($final);
exit;
}
}
function DBSelect($query, $debug = 0, $filterNil = 0) { //filterNil: 2 if nil or 0 should be removed from the data, 1 if only 0
$data = array();
if($result = $GLOBALS['mysqli']->query($query. " LIMIT 500")){
while($row=$result->fetch_assoc())
{
if($filterNil == 2){
$data[] =array_filter($row);
}
else if($filterNil == 1)
{
$data[] =array_filter($row , 'notZero');
}
else
{
$data[] = $row;
}
}
} else {
$final['error'] = "Database error.";
if($debug){
$final['debug'] = $debug;
$final['query'] = trim(preg_replace('/\s\s+/', ' ', $query));
$final['mysql_error'] = $GLOBALS['mysqli']->error;
}
echo json_encode($final);
exit;
}
return $data;
}
function notZero($var){
return ($var !== NULL && $var !== FALSE && $var !== '');
}
function DBInsert($inputArray, $table, $debug = 0) {
$query = "INSERT IGNORE INTO `{$table}` (`".implode("`, `", array_keys($inputArray))."`) VALUES ('".implode("', '", $inputArray)."') ";
if($result = $GLOBALS['mysqli']->query($query)){
return $GLOBALS['mysqli']->insert_id;
} else {
$final['error'] = "Database error.";
if($debug){
$final['debug'] = $debug;
$final['query'] = trim(preg_replace('/\s\s+/', ' ', $query));
$final['mysql_error'] = $GLOBALS['mysqli']->error;
}
echo json_encode($final);
exit;
}
return 0;
}
function DBUpdate($updateArray, $whereArray, $table, $debug = 0) {
$set = "";
foreach ($updateArray as $key => $value){
// add "," if it's not the first
if($set != ''){
$set .= ", ";
}
$set .= "`{$key}` = '{$value}'";
}
$where = "";
foreach ($whereArray as $key => $value){
// add "," if it's not the first
if($where != ''){
$where .= ", ";
}
$where .= "`{$key}` = '{$value}'";
}
$query = "UPDATE `{$table}` SET {$set} WHERE {$where}";
if($result = $GLOBALS['mysqli']->query($query)){
return 1;//$GLOBALS['mysqli']->insert_id;
} else {
$final['error'] = "Database error.";
if($debug){
$final['debug'] = $debug;
$final['query'] = trim(preg_replace('/\s\s+/', ' ', $query));
$final['mysql_error'] = $GLOBALS['mysqli']->error;
}
echo json_encode($final);
exit;
}
return 0;
}
function DBInsertOrUpdate($inputArray, $table, $debug = 0) {
$set = "";
foreach ($inputArray as $key => $value){
// add "," if it's not the first
if($set != ''){
$set .= ", ";
}
$set .= "`{$key}` = '{$value}'";
}
$query = "INSERT INTO `{$table}` (`".implode("`, `", array_keys($inputArray))."`) VALUES ('".implode("', '", $inputArray)."') ON DUPLICATE KEY UPDATE {$set}";
if($result = $GLOBALS['mysqli']->query($query)){
return $GLOBALS['mysqli']->insert_id;
} else {
$final['error'] = "Database error.";
if($debug){
$final['debug'] = $debug;
$final['query'] = trim(preg_replace('/\s\s+/', ' ', $query));
$final['mysql_error'] = $GLOBALS['mysqli']->error;
}
echo json_encode($final);
exit;
}
return 0;
}
Notice: Undefined index: Content-Type in /var/www/zumzet.ro/html/api/quizApp/index.php on line 10
Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'SQLUser'@'localhost' (using password: YES) in /var/www/zumzet.ro/html/api/quizApp/index.php on line 18
Failed to connect to MySQL: Access denied for user 'SQLUser'@'localhost' (using password: YES)
Warning: mysqli::set_charset(): Couldn't fetch mysqli in /var/www/zumzet.ro/html/api/quizApp/index.php on line 22
Warning: array_map() expects parameter 1 to be a valid callback, function 'array_map_callback' not found or invalid function name in /var/www/zumzet.ro/html/api/quizApp/index.php on line 37