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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:54:34+00:00 2026-06-01T08:54:34+00:00

$data = $mysqli->prepare(SELECT amount FROM items WHERE id=:id); echo ‘forward1’; if(!$data->execute(array(‘:id’ => $id))) die(error

  • 0
$data = $mysqli->prepare("SELECT amount FROM items WHERE id=:id");
echo 'forward1';
if(!$data->execute(array(':id' => $id)))
    die("error executing".$data->error);
echo '2';
$row = $data->fetch_object();
die('Losing my mind'.$row->amount);

This will only echo “forward1”, not “error executing…” or “2”. It works with *$mysqli->query”. If I add quotes ” to :id in the query, it will echo “forward1error executing”.

  • 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-01T08:54:35+00:00Added an answer on June 1, 2026 at 8:54 am

    First, make sure you understand the prepared statements syntax and working model.

    As in:

    $data = $mysqli->prepare("SELECT amount FROM items WHERE id=(?)");
                // THIS ^^ actually "prepares" an object to be used in the statement
    $data->bind_param("i",$id)
                // ...then you "bind" the parameter for your statement as "i"(nteger)
    echo 'forward1';
    if(!$data->execute())  // And now you simply run it, with no other args
        die("error executing".$data->error);
    echo '2';
    $row = $data->fetch_object();
    die('Loosing my mind'.$row->amount);
    

    I suggest though using something more like

    $data->execute() or die("error executing".$data->error);
    

    The main steps of a prepared statement are:
    1. Prepare the query with some placeholder values;
    2. “Bind” the required number of values to the query;
    3. Execute it!

    I fail to see why this is relevant in your case, with such a simple query. I also assume you actually need it for something bigger.
    Please let me know if I misunderstood your point or code sample.

    Oh, and.. have fun! 🙂

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

Sidebar

Related Questions

PHP session_start(); $username = $_POST['regduser']; $userpass = md5($_POST['regdpass']); $sql = $sql->prepare(SELECT * from Students
Here is a snapshot of my code: $fetchPictures = $PDO->prepare(SELECT * FROM pictures WHERE
I need to output data for javascript (array of array) from MySQL I am
This is the code: $q = $this->db->prepare(SELECT id FROM `users` WHERE username=? AND password=?
I have looped data from mysql, and it's a pretty long list. What's the
Exporting some data from mysql to a csv file using FasterCSV. I'd like the
How get data from mysql database? I use ASP.NET and C#.Previously, I used LINQ
I manipulated some data from MySQL and the resulting dictionary data (print data) displays
I am fetching data from mysql to a page, i am not sure if
Iam trying to retrieve data from mysql database into stylesheet.php but it is 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.