Jquery-file-upload the PHP mysql insertion problem

Source: Internet
Author: User
Tags php mysql
Recently used jquery-file-upload to improve the website upload experience

Https://github.com/blueimp/jQuery-File-Upload/wiki/PHP-MySQL-database-integration
Upload it in accordance with his reference document, immediately completed, and at the outset, according to his SQL schema first try

Results upload, can also be successfully inserted, JSON return to the page everything is OK!

But the problem comes with his SQL architecture ... There's a call URL.

But the author doesn't seem to be dealing with PHP in SQL.

Then I'll change it, ...

Some basic configurations are added first
$dir = $_cookie["UID"]. ' /'. Date ("Y"). ' /'. Date ("M"). ' /'. Date ("D"). ' /'; $dirUP =  ". /.. /.. /att/". $dir; $dirLink =  $dir; $options =array (    ' upload_dir ' + $dirUP,    ' upload_url ' + $dirLink,    ' delete_type ' + ' POST ',    ' db_host ' = ' localhost ',    ' db_user ' and ' root ',    ' db_pass ' + ' * * * * * ',    ' db_name ' = ' * * * * * * * *,    ' db_table ' and ' files ';



This is the part ....

I tried multiple times and the Join URL field was unsuccessful [original document code]
    protected function Handle_file_upload ($uploaded _file, $name, $size, $type, $error,            $index = null, $content _range = Nu ll) {        $file = parent::handle_file_upload (            $uploaded _file, $name, $size, $type, $error, $index, $content _range< c4/>);        if (Empty ($file->error)) {            $sql = ' INSERT into '. $this->options[' db_table ']                . ' ' (' name ', ' Size ', ' type ', ' title ', ' description ') '                . ' VALUES (?,?,?,?,?) ';            $query = $this->db->prepare ($sql);            $query->bind_param (                ' sisss ',                $file->name,                $file->size,                $file->type,                $ File->title,                $file->description            );            $query->execute ();            $file->id = $this->db->insert_id;        }        return $file;    }


Show me All:
Warning:mysqli_stmt::bind_param (): Number of elements in type definition string doesn ' t match number of BIND variables in

What does that mean, that I have a problem with the number? Does that mean I'm adding less?
I have changed to ... In this way, the Type field at 5 also adds a URL, which is also said to be a quantity problem?

    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, $co Ntent_range        );        if (Empty ($file->error)) {            $sql = ' INSERT into '. $this->options[' db_table ']                . ' ' (' name ', ' Size ', ' type ', ' url ', ' title ', ' description ') '                . ' VALUES (?,?,?,?,?,?) ';            $query = $this->db->prepare ($sql);            $query->bind_param (                ' sisss ',                $file->name,                $file->size,                $file->type,                $ File->url,                $file->title,                $file->description            );            $query->execute ();            $file->id = $this->db->insert_id;        }        return $file;    }


I need to save it as
$url = $_cookie["UID"]. ' /'. Date ("Y"). ' /'. Date ("M"). ' /'. Date ("D"). ' /'. FileName

How do you change it? Is it OK to use $file->url directly?




Other than that... Because this thing, also got a append value problem, cooked JQ friends can also go to these help younger brother
http://bbs.csdn.net/topics/390862894


Reply to discussion (solution)

Warning: Mysqli_stmt::bind_param (): The number of elements in a binding variable that does not match the type definition string
Isn't that clear?
$query->bind_param (
' Sisss ',//How can there be only 5 types of declarations?
$file->name,//1
$file->size,//2
$file->type,//3
$file->url,//4
$file->TITLE,//5
$file->description//6 a total of 6
);

Warning: Mysqli_stmt::bind_param (): The number of elements in a binding variable that does not match the type definition string
Isn't that clear?
$query->bind_param (
' Sisss ',//How can there be only 5 types of declarations?
$file->name,//1
$file->size,//2
$file->type,//3
$file->url,//4
$file->TITLE,//5
$file->description//6 a total of 6
);


Oh... The original question

It has been solved successfully!

Before the use of mysql_query after the switch to PDO, not used to Mysqli,pdo seems to have never mentioned the wording of this

Thanks, study.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.