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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:56:12+00:00 2026-06-09T20:56:12+00:00

This question is similar to this one: Why does mysql_query() return TRUE with a

  • 0

This question is similar to this one: Why does mysql_query() return TRUE with a SELECT statement?. I execute a SELECT mysql query in php, but it returns true. I’ve been starting at it for half an hour now and I’m completely positive it is a select query and it returns true. The obvious fix for the similar question was to check if the connection was still alive. The difference for me is, the mysql_error is empty. Here are the parts of my code that cause the error:

public function query($query, $params = array())
{
    $params['prefix'] = 'unpirate_';

    foreach($params as $key => $param)
    {
        $query = str_replace('{' . $key . '}',
            mysql_real_escape_string($param), $query);
    }

    echo($query);
    return mysql_query($query, $this->conn) or $this->error($query);
}

public function fetch_all($query, $params = array())
{
    $result = $this->query($query, $params);

    if($result === true)
        die('"' . mysql_error() . '"');
    (...)
}

The query that is echo’d is a valid query (SELECT * FROM [table] WHERE event_id = “54”) and the only other thing that is echo’d is “”, thus the result is true and the mysql_error is empty. Do you guys have any idea what is going on? Please correct me if my conclusion is not right.

PHP version: PHP 5.3.10-1ubuntu3.2 with Suhosin-Patch (cli) (built: Jun 13 2012 17:19:58)

MySQL version: mysql Ver 14.14 Distrib 5.5.24, for debian-linux-gnu (x86_64) using readline 6.2

  • 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-06-09T20:56:13+00:00Added an answer on June 9, 2026 at 8:56 pm
    return mysql_query($query, $this->conn) or $this->error($query);
    

    Your return value is an OR statement.

    What’s happening is that PHP is evaluating the OR and returning the value of that, rather than the code itself; because there’s data in the first part, it’s evaluating to true, and returning a boolean true.

    Try:

    $retVal = mysql_query($query, $this->conn);
    if (false === $retVal) {
        return $this->error($query);
    }
    return $retVal;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question very similar to this one but the answer does not
This question is similar to this one, but with an extra wrinkle: Auto-removing all
my question is similar to this one , but I don't want to use
My question is similar to this one , but I would like to replicate
(This question is similar to this one , but it's for using XMLHttpRequest instead
I know of a similar question that got closed. But this one is from
This question may be very similar to my one, but I cannot see the
This question is similar to this one about animation queues , but the answers
This is very similar to question 653714 , but for MySQL instead of SQL
This question is similar to this one How do I add options to a

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.