0

I am using a jquery-file-upload plugin with its own server-side file to run with. like here on github https://github.com/blueimp/jQuery-File-Upload/wiki/PHP-MySQL-database-integration

At first,everything went good,but after I added 2 other value to the database and to the PHP server-end files, it always return an error of 'SyntaxError: Unexpected token <'

here's my modifications of the codes:

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

    protected function handle_file_upload($uploaded_file, $name, $size, $type, $url, $error,
            $index = null, $content_range = null) {
        $file = parent::handle_file_upload(
            $uploaded_file, $name, $size, $type, $url, $error, $index, $content_range
        );

        if (empty($file->error)) {
            $sql = 'INSERT INTO `'.$this->options['db_table']
                .'` (`name`, `size`, `type`, `cat`, `url`, `title`, `description`)'
                .' VALUES (?, ?, ?, ?, ?, ?, ?)';
            $query = $this->db->prepare($sql);
            $url = get_download_url($name, $version = null);
            $file->url = $url;
            $query->bind_param(
                'sisss',
                $file->name,
                $file->size,
                $file->type,
                $file->cat,
                $file->url,
                $file->title,
                $file->description
            );
            $query->execute();
            $file->id = $this->db->insert_id;
        }
        return $file;
    }
oratis
  • 818
  • 1
  • 9
  • 29
  • This is why prepared statements in MySQLi suck, and I always recommend PDO: "sisss" – miken32 Aug 02 '16 at 03:33
  • Also, this is not the code causing that error message, since there isn't even a < in it. – miken32 Aug 02 '16 at 03:35
  • got some inspiring tips here:http://stackoverflow.com/questions/22517699/add-more-custom-variables-to-mysql-insert-on-blueimp-jquery-file-upload – oratis Aug 02 '16 at 03:53

0 Answers0