Blueimp adding custom variables

I want to add some my variables which have relation between other tables.
But script stops also I can’t see errors.

<?php
$options = array(
    'delete_type' => 'POST',
    'db_host' => 'localhost',
    'db_user' => 'root',
    'db_pass' => '',
    'db_name' => 'example',
    'db_table' => 'files'
);

error_reporting(E_ALL | E_STRICT);
require('UploadHandler.php');

class CustomUploadHandler extends UploadHandler {

    protected function initialize() {
        $this->db = new mysqli(
            $this->options['db_host'],
            $this->options['db_user'],
            $this->options['db_pass'],
            $this->options['db_name']
        );
        parent::initialize();
        $this->db->close();
    }

    protected function handle_form_data($file, $index) {
        $file->title = @$_REQUEST['title'][$index];
        $file->description = @$_REQUEST['description'][$index];
    }

    protected function handle_file_upload($uploaded_file, $name, $size, $type, $error,
            $index = null, $content_range = null) {
        $file = parent::handle_file_upload(
            $uploaded_file, $name, $size, $type, $error, $index, $content_range
        );
        if (empty($file->error)) {
            $sql = 'INSERT INTO `'.$this->options['db_table']
                .'` (`name`, `size`, `type`, `title`, `description`,'**myvariable1**','**myvariable2**')'
                .' VALUES (?, ?, ?, ?, ?,?,?)';
            $query = $this->db->prepare($sql);
            $query->bind_param(
                'sisss',
                $file->name,
                $file->size,
                $file->type,
                $file->title,
                $file->description,
                $file->myvariable1,
                $file->myvariable2
            );
            $query->execute();
            $file->id = $this->db->insert_id;
        }
        return $file;
    }

    protected function set_additional_file_properties($file) {
        parent::set_additional_file_properties($file);
        if ($_SERVER['REQUEST_METHOD'] === 'GET') {
            $sql = 'SELECT `id`, `type`, `title`, `description` FROM `'
                .$this->options['db_table'].'` WHERE `name`=?';
            $query = $this->db->prepare($sql);
            $query->bind_param('s', $file->name);
            $query->execute();
            $query->bind_result(
                $id,
                $type,
                $title,
                $description
            );
            while ($query->fetch()) {
                $file->id = $id;
                $file->type = $type;
                $file->title = $title;
                $file->description = $description;
            }
        }
    }

    public function delete($print_response = true) {
        $response = parent::delete(false);
        foreach ($response as $name => $deleted) {
            if ($deleted) {
                $sql = 'DELETE FROM `'
                    .$this->options['db_table'].'` WHERE `name`=?';
                $query = $this->db->prepare($sql);
                $query->bind_param('s', $name);
                $query->execute();
            }
        } 
        return $this->generate_response($response, $print_response);
    }

}

$upload_handler = new CustomUploadHandler($options);

Try this errorTesting.php file which may help you understand why the errors are not showing:

file: errorTesting.php

<?php 
        ini_set('display_errors',0);

        $errorLogFileNEW = 'errorLogFileNEW.php';

        echo '<br />' .__LINE__ .' : OLD: ' .ini_set('error_log', $errorLogFileNEW);

        echo '<br />' .__LINE__ .' : NEW: ' .ini_get('error_log');

        echo '<br />' .__LINE__ .' : Before $forceError/0 <br />';
        highlight_file($errorLogFileNEW);

        echo '<br />'.__LINE__ .$forceError/0;

        echo '<br />' .__LINE__ .' :  After $forceError/0 <br />';
        highlight_file($errorLogFileNEW);

        echo '<br />' .__LINE__ .' Show Errors - ini_set("display_errors",1);';
        ini_set('display_errors',1);

        echo '<br />' .__LINE__ .' : After: <br />';
        echo $i2/0;

        echo '<br />' .__LINE__ .' - filesize($errorLogFileNEW) = ' .filesize($errorLogFileNEW);
        highlight_file($errorLogFileNEW);

        $deleteErrorLog = 10;
        if( $deleteErrorLog && file_exists($errorLogFileNEW) ):
            $ok = unlink($errorLogFileNEW);
            if($ok):
                #echo '<br />' .__LINE__ .' Just deleted: ' .$errorLogFileNEW;
            endif;
        endif;    
    ?>

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.