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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:43:27+00:00 2026-05-31T14:43:27+00:00

I have a query that works in phpmyadmin however does not work in my

  • 0

I have a query that works in phpmyadmin however does not work in my code! I have tried various variable dumps to see if I have been loosing data before the query is executed, all seems ok, the same variables contents I have used in the successful query in phpmyadmin

To test I replaced:

$account_id = $account->getAccountId(); //output below
string(2) "59" string(4) "main" NULL NULL array(2) { ["id"]=> NULL["name"]=>NULL}

With

$account_id = 59; //output below
int(59) string(4) "main" NULL NULL array(2) { ["id"]=> NULL ["name"]=> NULL }

below is the code extract and I am using mysqli:

        $account = $Add_Profile_Image->getUserAccount();
        $account_id = $account->getAccountId();
        $status = $account->getType();
        var_dump($account_id);
        var_dump($status);
        $conn = $this->create_connection('read');
        $stmt = $conn->prepare('SELECT add_profile_images.image_id, image_name FROM add_profile_images, users_profile_images WHERE users_profile_images.account_id=? AND users_profile_images.status=?');
        $stmt->bind_param('is',$account_id,$status);
        $stmt->bind_result($id,$imageName);
        $stmt->execute();
        var_dump($id);
        var_dump($imageName);
        $result['id'] = $id;
        $result['name'] = $imageName;

I have replaced

image_name //in the query

To

add_profile_images.image_name //in the query

but the result is still NULL?

So I have tried the following examples in this post: PHP Prepared Statement Returns -1
When I dump the mysqli object it does return -1 however when I implement the below no errors
are shown!

if($conn->connect_error) {
            printf('connect error (%d) %s', $conn->connect_errno, htmlspecialchars($conn->connect_error));
                        die;
        }
        $stmt = $conn->prepare('SELECT add_profile_images.image_id, add_profile_images.image_name FROM add_profile_images, users_profile_images WHERE users_profile_images.account_id=? AND users_profile_images.status=?');
        if ( false===$stmt ) {
            printf('prepare failed: %s', htmlspecialchars($conn->error));
            die;
        }

        $rc = $stmt->bind_param('is',$account_id,$status);
        if ( false===$rc ) {
            printf('bind_param failed: %s', htmlspecialchars($stmt->error));
        die;
        }

        $rc= $stmt->execute();
        if ( false===$rc ) {
                printf('execute failed: %s', htmlspecialchars($stmt->error));
                die;
        }
        $rc = $stmt->bind_result($id,$imageName);
        if ( false===$rc ) {
                printf('bind_result failed: %s', htmlspecialchars($stmt->error));
                die;
        }

Where am I going wrong?

Hope someone can help!

Thanks

  • 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-31T14:43:28+00:00Added an answer on May 31, 2026 at 2:43 pm

    You need to state $stmt->bind_result() AFTER $stmt->execute()
    (see: http://php.net/manual/en/mysqli-stmt.bind-result.php)

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

Sidebar

Related Questions

I have a problem with a query that works in phpmyadmin but not with
I have a query that works on Postgresql 7.4 but not on Postgresql 8.3
I have a query, which when run from within phpMyAdmin, it works, however when
I am using in C# MYsql .I have query that works if I run
So I have this query that works perfectly: SELECT users.*, GROUP_CONCAT(categories.category_name) AS categories FROM
I have this linq query that works well (although it may be written better,
I have written a SQL query that works just fine, but am having a
I have a SQL query that I'm trying to debug. It works fine for
i have created this query that works OK: $q1 = Doctrine_Query::create() ->from('Usuario u') ->leftJoin('u.AmigoUsuario
I have this query that works: select name, location_id from all_names where location_id in

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.