mysql_error: Undeclared variable: INF
PHP Code:
$limit = 10;
$page = isset($_GET['p']) ? $_GET['p'] : 1;
$offset = ($page - 1) * $limit;
$sql = "SELECT * FROM articles WHERE category_id LIMIT $offset, $limit";
echo $sql;
Reason:
?p=10000....0 (many many character '0')
$page - 1 will return INF
INF * $limit will return INF
=> SQL error
Fix:
$page = isset($_GET['p']) ? (int)$_GET['p'] : 1;
if ($page < 1) $page = 1;
Title:
mysql_error: Undeclared variable: INF
Description:
mysql_error: Undeclared variable: INF PHP Code: $limit = 10; $page = isset($_GET['p']) ? $_GET['p'] : 1; $offset = ($pa...
...
Rating:
4