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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:57:50+00:00 2026-06-17T06:57:50+00:00

I am writing a program that will receive values through URL and then will

  • 0

I am writing a program that will receive values through URL and then will either add an entry to the MySQL database, delete it or if someone else has booked that slot then it will not let you delete it.

The add and delete functions are as follows:

function addBooking($id, $desk, $member, $date){
    global $dbconn;
    $query = $dbconn -> prepare("INSERT INTO booked (booking_id, desk_id, member_id, date_booked) VALUES (?,?,?,?)");
    $query -> bind_param("iiis", $id, $desk, $member, $date);
    $query->execute();
    print '<div class="yours" title="Your Booking">Your Booking</div>';
    $query -> close();
}

function delBooking($id, $desk){
    global $dbconn;
    $query = $dbconn -> prepare("DELETE FROM booked WHERE booking_id = ? AND desk_id = ?");
    $query -> bind_param("ii", $id, $desk);
    $query->execute();
    print '<div class="free" title="Click To Book">Not Booked</div>';
    $query -> close();
}

And the code that calls them is this:

$query = $dbconn -> prepare("SELECT firstname, lastname, booked.member_id, date_booked FROM members, booked WHERE (members.member_id = booked.member_id) AND booking_id = ? AND desk_id=?");
    $query -> bind_param("ss", $booking_id, $desk_id);
    if($query->execute() == true) {
        $query -> bind_result($fname, $lname, $memid, $dbooked);
        $query -> fetch();
        if($fname){
            if ($memid == $member_id)
            {
                delBooking($booking_id,$desk_id);
            }
            else
            {
                print '<div class="taken" title="Booked by <strong>'.$fname.' '.$lname.'</strong><br>On '.$dbooked.'">Booked</div>';
            }
        }else{
            addBooking($booking_id,$desk_id,$member_id,$date);
        }
    }

It adds a booking fine and will also tell you if someone else has booked it fine, but if you run it again on your own booking it will give you the error:

Fatal error: Call to a member function bind_param() on a non-object in /var/www/new/functions/functions.php on line 80

I’m not sure why. It’s not my delete statement or anything because I can rename the addBooking function to delBooking so it’s identical working code and it still gives me exactly the same error :/

  • 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-17T06:57:52+00:00Added an answer on June 17, 2026 at 6:57 am

    When using mysqli, you cannot have more than one prepared statement active on a single connection at the same time. By active I mean is has been sent over to the server by calling it’s execute() at least once. You can have as many unused statements prepared, but you can only execute on one at a time. When done, you need to close the statement before you execute another. Before you call delBooking() close the earlier statement:

    $query->fetch();
    $query->close();
    if($memid == $member_id){
        delBooking(....);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a program that sends an array through a function (upperhess) that will
I am writing a program, for homework, that will add 2 8-bit binary numbers.
I am contemplating writing a program that will move some newly created dirs to
I'm a writing a program that will determine the number of lines, characters, and
I'm writing a simple program that will run entirely client-side. (Desktop programming? do people
I am writing an HTML program that will be accessed by over 500 people
I'm writing a program in C# that will need to store a few Data
I'm writing a program that will have both a server side and a client
I am writing a program that will need to measure time in minutes. To
I'm writing a program that will do image processing on a 16 bit tiff

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.