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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:16:47+00:00 2026-05-21T12:16:47+00:00

Before anyone jumps on me, I have found a similar issue here , but

  • 0

Before anyone jumps on me, I have found a similar issue here, but unfortunately their answer does not seem to apply to my problem.

I have created a function called sqlReturn() in order to more easily produce an error (with standard output) should a query go wrong. The code is below:

function sqlResult($query)
{
    return mysql_query($query) 
    or die("SQL Query: " . $query . "<br />SQL Error: " . mysql_error());
}

As you can see, it just outputs an error in the way I like, and it saves me a bit of effort in coding along the way. However, while this has been working in most cases (eg. situations where I use SELECT or INSERT), it is throwing the following error:

PHP Warning:  mysql_fetch_array() expects parameter 1 to be resource, 
              boolean given in /var/www/login/login_submit.php on line 42

It is returning 1 instead of a resource. If, instead of calling that function (which is in a separate php file), I simply use the line of code in the same file without a return statement
(ie. $sqlResult = mysql_query($sqlQuery) or ... etc.), it returns a resource as normal.

In case it’s relevant, my SQL query is also below:

$sqlQuery = 
  "SELECT userID, username, password, access_level
   FROM users
   WHERE username = '{$username}'
   AND (password = '{$password_sha1}' OR password = '{$password_sha256}')";

Any input on this would be appreciated.

Thanks,

Paragon

  • 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-21T12:16:48+00:00Added an answer on May 21, 2026 at 12:16 pm

    Sneaky suspicion that binding rules are kicking in here. PHP may be seeing your function as

    return (mysql_query(...)) or die(...);
    

    and return before ever seeing the die(). Try rewriting like this

    function sqlQuery(...) {
        $result = mysql_query(...);
        if ($result === FALSE) {
            die(mysql_error(...));
        }
        return $result;
    }
    

    so there’s no chance of any mis-parsing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(Before anyone says anything Yes this was homework but i have already turned it
(Before anyone asks, it's not homework.) Say you have 2 Arrays y0 and y1
Anyone had this issue where the page quickly jumps to the top before a
Ok, before anyone attempts to label this as a duplicate, I am not asking
Has anyone ever run into this issue before? Sometimes the string displays, sometimes half
Has anyone come across this issue before?
Does anyone know how to set the working directory in JavaScript before? Code I
Before anyone closes this as duplicate - please note its not a linq or
Before anyone says try searching, I have - I realize this is probably a
I have secure site with a login before anyone can enter the site and

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.