English 中文(简体)
定值美元
原标题:Validating $_GET
  • 时间:2009-11-13 04:54:13
  •  标签:
  • php

• 支付费用 GET将数字从正确来源得出。

My url 看像:指数.php?page=items&catID=5

当用户提出像3类的东西时,在散射电离层上就不存在。 我希望它能够显示错误信息。

$catID = intval($_GET["catID"]);

if($catID) {
    $checkSQL = mysql_query("SELECT * FROM category WHERE category_type= 2 ");
    while($checkROW = mysql_fetch_array($checkSQL)) {
    $checkCAT != $checkROW["categoryID"];
    echo "err msg";
    }

这一点迄今为止可以出现,但是,即便在正确的网页上发生火灾错误,也无所作为。

谢谢。

最佳回答

隔离墙是好的,如果是的话,就存在失踪人员。 但是,如果正确读到这一点,那么你会做些什么呢? 现在是:

if($catID) {

实际上,只有卡迪卡(或,从_GET美元中支离破碎)是非零的(不是假的)。 我的猜测是,如果要检查一下信息数据库是从KQ返回的类别?

$catID = intval($_GET["catID"]);

checkcat($catID);

function checkcat($check_category) {
    $checkSQL = mysql_query("SELECT * FROM category WHERE category_type= 2 ");
    while($checkROW = mysql_fetch_array($checkSQL)) {
        if ( $check_category != $checkROW["categoryID"] ) {
            echo "err msg";
        } else { 
            echo "not an error message";
        }
    }
}

了解你所期待的是什么,为什么像现在这样?

$catID = ($_GET["catID");

if ( !is_numeric($catID) ) {
    echo "Not a numeric category!"
} else {
    $checkSQLQuery = "SELECT * FROM category WHERE categoryID =  {$catID}  AND category_type= 2 "
    $resultSQL = mysql_query($checkSQLQuery, $db);
    /* NOTE!:  Guessing on what your database resouce 
    pointer is - it isn t included in the origin snippet.
    Although, the last opened should be used by default if 
    this is left out. */
    if ( mysql_num_rows($resultSQL) < 1 ) {
        echo "Error message, category ID not found" 
    } else {
        echo "Found it!"
    }
}
问题回答

见Oh先生。 第1行“如果”

    while ($checkROW = mysql_fetch_array($checkSQL)) {
        if ($checkCAT != $checkROW["categoryID"])
            echo "err msg";

它想像你想要使用我的sql_fetch_assoc,而不是我的sql_fetch_array()。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签