在where子句中找不到列

时间:2016-06-02 04:17:38

标签: php mysql

我是php,我正在尝试创建一个页面,您可以在其中看到存储在mysql服务器中的公共上传。

不在我使用过的代码的地方开始给我一个错误:

  

SQLSTATE [42S22]:未找到列:1054未知列' public'在' where子句'

我正在尝试查看我的数据库中有多少行有' public'

// Find out how many items are in the table
$p = 'public';
$total = $db->query("SELECT COUNT(*) FROM uploads WHERE world_access = $p")->fetchColumn();

我不知道它是php还是sql。

// Prepare the paged query
$stmt = $db->prepare('SELECT * FROM uploads WHERE world_access = :y ORDER BY upload_time DESC LIMIT :limit OFFSET :offset');
// Bind the query params
$stmt->bindParam(':y', $p, PDO::PARAM_INT);
$stmt->bindParam(':limit', $limit, PDO::PARAM_INT);
$stmt->bindParam(':offset', $offset, PDO::PARAM_INT);
$stmt->execute();
{p> Simple PHP Pagination script

分页

1 个答案:

答案 0 :(得分:1)

用引号括起$total = $db->query("SELECT COUNT(*) FROM uploads WHERE world_access = '$p'")->fetchColumn();

:y

同样在你的PDO中,PDO::PARAM_STR是正确的吗?然后使用 allfiles = dir; %get files allname = {allfiles(~[allfiles.isdir]).name}; set(handles.wavlist, 'String', allname); function wavlist_Callback(hObject, eventdata, handles) filenames = get(hObject, 'String'); filechoice = get(hObject, 'Value'); fileselected = wavnames{filechoice}; function wavlist_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function tab1button_Callback(hObject, eventdata, handles) [y, fs, nbits, opts] = wavread(fileselected);