小编Han*_*urr的帖子

只接受数字作为 GET 变量

你好,

我只想在$_GET方法中允许使用数字。我在分页中使用它来确保安全

$page = (isset($_GET['page']) && is_numeric($_GET['page']) ? (int) $_GET['page'] : 1);

如果我输入特殊字符或字母,它会返回错误

这应该是不可能的:

index.php?page=AAindex.php?page='!@#$%^&*()

只有这个: index.php?page=12 ...

有人有解决方案吗?:) 提前致谢...

php get

1
推荐指数
1
解决办法
2588
查看次数

编码一个完美的json

我有这个代码

$md_query = "SELECT * FROM table ORDER BY id ASC";
$md_result = mysql_query($md_query, $con);

header('Cache-Control: no-cache, must-revalidate');
header('Content-type: application/json');

while($md_row=mysql_fetch_array($md_result))
    $data_row = array(
        'id' => $md_row['id'],
        'type' => $md_row['type'],
        'title' => $md_row['title'],
        'content' => $md_row['content'],
        'author' => $md_row['postedby'],
        'post_date' => $md_row['posteddate'],
        'publish' => $md_row['publish']
    );

print json_encode($data_row); `
Run Code Online (Sandbox Code Playgroud)

但我只显示1条记录......有人如何解决这个问题?

php mysql arrays json

0
推荐指数
1
解决办法
349
查看次数

标签 统计

php ×2

arrays ×1

get ×1

json ×1

mysql ×1