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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:25:40+00:00 2026-06-02T22:25:40+00:00

i am trying to update my records using UPDATE in php and mysql ,

  • 0

i am trying to update my records using UPDATE in php and mysql , the query working but there is not updates at all happened on the database , i have many records for tickets which i need to update there status when the user purchase them , let say the user books 10 tickets i used this syntax

     for ($counter = 1; $counter <= $tickets; $counter++) {
                echo $eventId;
                echo $chooseClass;
                echo $chooseUser;
                $bookTicket = mysql_query("UPDATE units 
SET ticketSold = 'Yes', 
userIdFK = '$chooseUser' 
WHERE BusinessreservationIdFk = '$eventId' 
AND classIDfk ='$choosedClass'"
) or die(mysql_error());

                if ($bookTicket) 
                {
                    echo "<br/>ticket " . $counter . "  done !";
                } 
                else
                {

i tried to echo all variables here inside the for loop to make sure this for gets all the variables values , which is working , i have like 1000 tickets already stored on mysql table units which i need to update their status from sold = No to Yes. where is the problem here ?

  • 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-02T22:25:42+00:00Added an answer on June 2, 2026 at 10:25 pm

    try building the query separately (e.g. $sql = 'UPDATE ...', so you can do an echo $sql and copy/paste the query and run it manually. Nothing in your code looks wrong, so the values you’re passing around must not be correct or the WHERE ... logic isn’t proper. So run a sample query manually and see if anything happens then.

    However, note that you’re doing this inside a for() loop, but aren’t using that $counter value anywhere. In effect you’re just running the SAME query over and over. Setting ticketSold to Yes $counter times isn’t going to make it “more” Yes than if you’d done this update only once.

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

Sidebar

Related Questions

I'm trying to get php to update a MySQL table using UPDATE statement but
I am trying to update an existing record in a database using CoreData, but
I'm trying to update a collection of records in my database using ActiveRecord's update_all.
I'm trying to delete a li item using jquery, but its not working. Here's
Using Linq, trying to select all records not in my local set fails: var
I am trying to update all records in a column so that they start
I'm trying to update many active records at the same time using the :update
How can I update multiple records in a database using one Update statement where
Im trying to update my DB using AJAX and PHP. I'm sure everything is
I'm trying to update the records in an Access database where the column Group

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.