Check empty select in sqlite? Check empty select in sqlite? sqlite sqlite

Check empty select in sqlite?


Note that sqlite_fetch_array() returns a result handle, not the number of rows, so you should not compare it against zero:

This function will return a result handle or FALSE on failure.

Use sqlite_num_rows() to determine the number of rows returned, e.g.

if(sqlite_num_rows($result) !== 0) {  ...} else {  ...}

Note that you should not use user-provided data by directly incorporating it in the SQL query as that allows for SQL injection attacks. Also, make sure that the contents of your database, particularly values in columns img1 and id are properly escaped or you risk being vulnerable to XSS attacks.


You could check number of returning rows using sqlite_num_rows() function

http://www.php.net/manual/en/function.sqlite-num-rows.php


Looks on http://php.net/manual/en/function.sqlite-num-rows.php

$rows = sqlite_num_rows($result);

where $rows will be 0 if the result is empty