php - Column not found in where clause -


i php , trying make page can see public uploads stored in mysql server.

out of not code have been using starts giving me error:

sqlstate[42s22]: column not found: 1054 unknown column 'public' in 'where clause'

i trying see how many rows in db have 'public'

// find out how many items in table $p = 'public'; $total = $db->query("select count(*) uploads world_access = $p")->fetchcolumn(); 

i don't know if php or sql.

// prepare paged query $stmt = $db->prepare('select * uploads world_access = :y order upload_time desc limit :limit offset :offset'); // bind 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(); 

pagination simple php pagination script

enclose $p quotes

$total = $db->query("select count(*) uploads world_access = '$p'")->fetchcolumn(); 

also in pdo, :y string right? use pdo::param_str


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo