我正在使用 Jquery File Upload,它似乎是一个不错的插件,但我对查询中的 select 语句有很大的问题。 数据库中的“描述”列包含数字 5,但不幸的是,经过多次尝试,它仍然不起作用。
我还尝试更改 session_id:在此处输入代码
protected function get_user_id() {
@session_start();
return session_id();
}
与:
protected function get_user_id() {
@session_start();
return $_session['description'];
}
我希望有人能有解决方案,我看了很多论坛,但似乎没有一个是永远做不到的。 对不起我的英语 提前谢谢了 强尼
protected function set_additional_file_properties($file) {
parent::set_additional_file_properties($file);
$cr='5';
if ($reqMeth = 'GET') {
$sql = 'SELECT `id`, `type`, `title`, `description` FROM `'
.$this->options['db_table'].'` WHERE `description`=?';
$query = $this->db->prepare($sql);
$query->bind_param('i', $cr);
$query->execute();
$query->bind_result(
$id,
$type,
$title,
$description
);
while ($query->fetch()) {
$file->id = $id;
$file->type = $type;
$file->title = $title;
$file->description = $description;
}
}
}
最佳答案
您已将 $cr 声明为字符串,但将其作为整数传递。这可能是问题所在吗?
$cr='5'; /* <------------ string */
if ($reqMeth = 'GET') {
$sql = 'SELECT `id`, `type`, `title`, `description` FROM `'
.$this->options['db_table'].'` WHERE `description`=?';
$query = $this->db->prepare($sql);
$query->bind_param('i', $cr); /* <---- integer passing */
尝试将 $cr 参数作为字符串传递。还要验证 description 是一个 varchar 类型的字段。
$query->bind_param('s', $cr);
如果你在数据库中的描述实际上是integer
字段,你可能想把第一行改成
$cr= 5;
可能值得一试。
关于mysql - jquery文件上传-查询选择Mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28970894/