Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 454695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:17:47+00:00 2026-05-12T22:17:47+00:00

How do i validate $_GET thats the number coming from correct source. My url

  • 0

How do i validate $_GET thats the number coming from correct source.

My url look like : index.php?page=items&catID=5

When users put something like 3 which is doesn’t exist on catID. I want it to display error message.

$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";
    }

This i can come up so far but it doesn’t working as it fire error msg even in correct page.

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T22:17:48+00:00Added an answer on May 12, 2026 at 10:17 pm

    wallk makes a good point, there is a missing if. but if i read this correctly, wouldn’t something along the lines of this be more what you are going for? Right now the line:

    if($catID) {
    

    is actually only checking if catID (or, catID from the $_GET) is non-zero (not false). My guess if you are looking to check if catID is the categoryID returned from SQL?

    $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";
            }
        }
    }
    

    Expounding on what you are looking for, how about something like this then?

    $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!"
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I validate that my ASPNET AJAX installation is correct. I have Visual
I have a DateTime property in my model and I would like to validate
I'm working on a regression-testing tool that will validate a very large number of
I'm running my site through the W3C's validator trying to get it to validate
When you're passing variables through your site using GET requests, do you validate (regular
Calling Validate() on an XmlDocument requires passing in a ValidationEventHandler delegate. That event function
I need to validate a date/time field on a webpage but want it to
Is it possible to validate an xml file against its associated schema using Visual
I need to validate an XML string (and not a file) against a DTD
I am trying to validate user id's matching the example: smith.jack or smith.jack.s In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.