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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:47:37+00:00 2026-05-25T14:47:37+00:00

My query does no return anything for my second index. It always sends me

  • 0

My query does no return anything for my second index. It always sends me a message Notice: Undefined offset: 1. I tried doing with a for it is the same result, so I have read that my problem it is in the query, somebody told me let $stmt be null for freeing resources of my statement. I dont know what is wrong.

These are my methods. I dont know what to someone say use $database->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true);

Example: $arrayDirectory[] = {'user1', 'user2'};

It must echo 1 2 but just prints me 1

for($i=0;$i<sizeof($arrayDirectory;$i++){ 
    $res[$i] = $obj->obtainID($arrayDirectory[$i]);

    echo $res[$i];
}

This is my obtainID method:

public function obtainID($user){
        $conexion = $this->objConexion->configuracion();
        $query = "CALL sp_xxx('$user')";
        $stmt = $conexion->prepare($query);
        $stmt->execute();
        $resultado = $stmt->fetchColumn();
        return $resultado;
    }

$stmi = null where?

  • 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-25T14:47:38+00:00Added an answer on May 25, 2026 at 2:47 pm

    For one,

     $arrayDirectory[] = {'user1', 'user2'};
    

    is a syntax error. { ... } does not work for arrays in PHP. Maybe it’s just a typo and you’re getting PHP confused with javascsript.

    But the bigger issue is the []. That tells PHP to treat $arrayDirectory as an array (fine), but PUSH as a single value whatever you’re assigning.

    If your code was really:

    $arrayDirectory[] = array('user1', 'user2');
    

    This would create the following structure:

    array(1) {
      [0]=>
      array(2) {
        [0]=>
        string(5) "user1"
        [1]=>
        string(5) "user2"
      }
    }
    

    Note that it’s a 2-level array. A top level single-element array at index [0]. That element at 0 contains ANOTHER array, which contains your two usernames.

    You should have this instead:

    $arrayDirectory = array('user1', 'user2');
    
    $res = array();
    foreach($arrayDirectory as $user) {
        $res[] = $obj->obtainID($user);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I make the same query twice, the second time it does not return
Why does the following query return 'zero' records: SELECT * FROM records WHERE rownum
Update : Looks like the query does not throw any timeout. The connection is
The following query does what I'd like it to do, however, I have no
I have a query that does what i want joining table but i need
I need to do a LINQ2DataSet query that does a join on more than
I am trying to optimize a query that does something like this: SELECT ...
I just came across a query that does an inner join on a non-distinct
I have written a LINQ to XML query that does what I want, but
I want to make sure a file path set via query string does not

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.