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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:58:49+00:00 2026-06-06T05:58:49+00:00

I have tried different methods and none of them seem to work. When I

  • 0

I have tried different methods and none of them seem to work. When I try the command in the MySQL console it works fine, but when I try it in this PHP script it sends me back an empty string.

$search = $mysqli->prepare("SELECT item_path FROM items WHERE item_title = ?");

while (array_key_exists($i, $parts)) {
    // An array that contains (word1, word2, word3)
    $data = $parts[$i];

    // Wraps data in "" for mysqli query
    $data = "\"" . $data . "\"";

    // Binding here still doesn't work
    $search->bind_param("s", $data);

    // This should execute the above prepare and give me the data
    // from the way I think it work's this execute() should use the updated $data
    $search->execute();
    $search->bind_result($img_path);
    $search->fetch();

    // This returns an empty string
    echo $img_path;
    echo "<img src= \"", $img_path, "\" >";

    $i++;
}

If I go into the MySQL console and run:

SELECT item_path FROM items WHERE item_title = "word1"

I get the item_path I am expecting but for some reason it my script it returns an empty string.

Thanks in advance for helping (if you do)!

EDIT:

    // Wraps data in "" for mysqli query
    $data2 = "\"" . $data . "\"";

    // Binding here still doesn't work even after changing the var
    $search->bind_param("s", $data2);

I tired to change the bind to another variable, but still I get an empty string. I’m not sure if it’s cause I’m wraping the data incorrectly or if there is another reason. I have been searching for something else like this to happen and I have came up with nothing.

  • 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-06T05:58:52+00:00Added an answer on June 6, 2026 at 5:58 am

    You bind your statement outside of the clause, and you never use the $data that you changed.

    $search = $mysqli->prepare("SELECT item_path FROM items WHERE item_title = ?");
    
    while (array_key_exists($i, $parts)) {
        // An array that contains (word1, word2, word3)
        $data = $parts[$i];
    
        // Wraps data in "" for mysqli query
        $data = "\"" . $data . "\"";
    
        // Bind it here instead!
        $search->bind_param("s", $data);
    
        // This should execute the above prepare and give me the data
        $search->execute();
        $search->bind_result($img_path);
        $search->fetch();
    
        // This returns an empty string
        echo $img_path;
        echo "<img src= \"", $img_path, "\" >";
    
        $i++;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried many different languages and copied various examples, but none of my
I've tried going about this three different ways, none of them have worked. The
I have tried many other questions on this site today but none of them
OK i have tried a lot of different methods for this. I want to
I have one key but different values for that key. I tried HashTable but
I have tried two different methods. The first is to specify the link in
I have a small problem, I have tried different solutions to add a image
I have tried lots of different ways, and using many diffent PHP and JS
I have tried this a few different ways and it always seems to fail.
Play 1.2.4 Morphia 1.2.6a I have tried to update a record a few different

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.