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

  • SEARCH
  • Home
  • 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

Ask A Question

Stats

  • Questions 231k
  • Answers 231k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use the following function like this: Image('/path/to/original.image', '1/1', '150*', './thumb.jpg');… May 13, 2026 at 2:13 am
  • Editorial Team
    Editorial Team added an answer Check you database schema to see if the field (referenced… May 13, 2026 at 2:13 am
  • Editorial Team
    Editorial Team added an answer I figured out the problem - there was a session… May 13, 2026 at 2:13 am

Related Questions

I've created a 3 screen wizard using the Zend_Form_SubForm example from the online reference
Is there a way to get an ASP.NET textbox to accept only currency values,
My form: class PlanForm(forms.ModelForm): owner = forms.ModelChoiceField(label=, queryset=Profile.objects.all(), widget=forms.HiddenInput()) etc... class Meta: model =
For the following header I get the same two errors on all my sitemaps.
I am reading a binary log file produced by a piece of equipment. I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.