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 6730481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:24:49+00:00 2026-05-26T10:24:49+00:00

I am getting a variable from $_GET[‘category’] . This is always supposed to be

  • 0

I am getting a variable from $_GET['category']. This is always supposed to be a integer. So when I set the variable I use:

$category=settype($_GET['category'], "int");
// Also tried
$category=settype($_GET['category'], "integer");

However, this always returns 1. They are numbers in the query string for example:

http://domain.com/example.php?category=57

When I echo $category it always returns 1. No mater what ?category= has behind it for a number.

Any help would be appreciated! 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-26T10:24:50+00:00Added an answer on May 26, 2026 at 10:24 am

    settype modifies the type of the variable. You’re using it as if it would return a new variable.

    However, settype returns true if the type change was successful, and false otherwise. You’re seeing the result 1 since that’s the string representation of true.

    You should either use casting, or intval:

    $category = (int) $_GET['category']; // or ...
    $category = intval($_GET['category']);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting this notice Undefined variable: _ in magic_quotes_gpc.php on line 43 from this
I'm trying to set a static pointer variable in a class but I'm getting
I have two foreach statements. The variable from one one is somehow getting into
I am trying to use this answer from an old post: Display image from
Right now I have this: session_start() $_SESSION['title'] = $_POST['title']; I store a variable from
Possible Duplicate: Accessing inherited variable from templated parent class There's this class: template<typename T>
I have a problem where a method is getting an undefined variable error, even
In MATLAB, how do you tell where in the code a variable is getting
I am having problems getting JBoss to inject an environment variable value into a
I am getting Bus Error trying to read stdin into a char* variable. I

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.