我使用BlueImp jQuery File Upload进行数据库集成,调整script found here。
我改变了handle_file_upload()
这样的方法:
$sql = 'INSERT INTO '.$this->options['db_table'].' (`path`, `type`, `tab`, `item`) VALUES (?, ?, ?, ?)';
$query = $this->db->prepare($sql);
$query->bind_param(
'ssii',
$path = $this->options['upload_url'] . $file->name,
$file->type,
$file->tab,
$file->item
);
但是,在$path = $this->options['upload_url'] . $file->name
行上,我有一个Strict Standards: Only variables should be passed by reference
错误
好吧,我不知道如何改变这个......
我试着看看其他答案,但它们不适合我的情况:请帮忙吗?感谢
答案 0 :(得分:4)
由于它是通过引用传递的,因此变量需要在绑定之前存在
$path = $this->options['upload_url'] . $file->name;
$sql = 'INSERT INTO '.$this->options['db_table'].' (`path`, `type`, `tab`, `item`) VALUES (?, ?, ?, ?)';
$query = $this->db->prepare($sql);
$query->bind_param(
'ssii',
$path,
$file->type,
$file->tab,
$file->item
);
答案 1 :(得分:2)
这应该有用......
$sql = 'INSERT INTO '.$this->options['db_table'].' (`path`, `type`, `tab`, `item`) VALUES (?, ?, ?, ?)';
$query = $this->db->prepare($sql);
$p = $this->options['upload_url'] . $file->name;
$query->bind_param(
'ssii',
$p,
$file->type,
$file->tab,
$file->item
);
您在参数绑定中设置了$ path的值。所以它不会返回任何东西。
答案 2 :(得分:1)
在此处阅读更多内容:Strict Standards: Only variables should be passed by reference
$sql = 'INSERT INTO '.$this->options['db_table'].' (`path`, `type`, `tab`, `item`) VALUES (?, ?, ?, ?)';
$query = $this->db->prepare($sql);
$upload_url = $this->options['upload_url'] . $file->name;
$query->bind_param(
'ssii',
$path = $upload_url,
$file->type,
$file->tab,
$file->item
);