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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:01:49+00:00 2026-05-20T05:01:49+00:00

Sorry if this question may seem easy to some but i cannot seem to

  • 0

Sorry if this question may seem easy to some but i cannot seem to figure it out. i was told that i could come here because the guys here are very helpful. i am having problem with the following code. when the uid is call into the url for example page.php?uid=5 i get “some code” if i do page.php?uid=letters i get redirected to page.php?uid=1. that works fine. but if a user should enter page.php?uid=1letters i get this error..Unknown column ‘1gh’ in ‘where clause’

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\page.php on line 173.

i only get this error if the user enters unwanted characters at the end of get url id. How can i prevent this from happen how can i have it redirect to page.php?uid=1… see code below

$id = mysql_real_escape_string(@$_GET['uid']);

$query = mysql_query("SELECT user.* FROM user WHERE id = '$id'");

if ((mysql_num_rows($query)==0)) {
    header("location:page.php?uid=1");
    die();
}
else {
    while($rows = mysql_fetch_array($query)){
        $foo = $row['foo'];

        echo "some code";
  • 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-20T05:01:49+00:00Added an answer on May 20, 2026 at 5:01 am

    mysql_query returns false on error. You should check what it returns:

    $query = "SELECT user.* FROM user WHERE id = '$id'"
    $result = mysql_query($query);
    
    if ($result === false) {
        die($query.'<br/>'.mysql_error());
    }
    

    Then you can understand why it failed. I’ve added the query to the die() statement so you can try the query manually as well.

    The error given is unknown column of a string, which suggests you are not enclosing the value with single quotes in the SQL query, even though the code in the question does.

    In production you should be taking all steps you can to ensure errors are handled gracefully. In this case you will probably want the same behaviour as not finding a user:

    header("location:page.php?uid=1");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry that this may seem like a rookie question, but it's a real pain
Sorry if this question may be simple, but I can't seem to find an
Hi sorry for repeating this question but i cant figure out what am i
Sorry, this may or may not be a programming question directly, but I am
Sorry if this question is very easy, but I can't find the answer anywhere.
Hello yeah I'm asking this question a second time, sorry about that but I
I can't figure out how to phrase this question to be honest. :/ But
I am sorry ahead of time for how this question may turn out. I
This may seem like a silly question if so sorry =] Ok i have
Hey guys sorry this is a pretty long question but I cannot call printPASSInfo()

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.