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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:10:12+00:00 2026-06-02T20:10:12+00:00

i have a problem my script has three mysql_query which should be used after

  • 0

i have a problem my script has three mysql_query which should be used after each other , i am trying to create a script that reserve tickets by changing their status from sold = “No” to “Yes”, the script count the number of tickets user has entered on html form which give the server side a variable with number of tickets called = $tickets.

hint : this is such a model so no need for mysql injection security

here is my code :

//get ticket status
    $eventTicket = mysql_query("SELECT eventTickets FROM beventreservation WHERE eventId = '$eventId'") or die(mysql_error());
    $ticketrow = mysql_fetch_array($eventTicket) or die(mysql_error());


    //test... which is working !
    echo $ticketrow['eventTickets'];


    //get classId from classes
    $selectClass = mysql_query("SELECT classId FROM quotaclasses WHERE className = '$classes' AND eventFK = '$eventId'") or die (mysql_error());    

    $classrow = mysql_fetch_array($selectClass) or die(mysql_error());

    //this var is to define which class the user used
    $choosedClass = $classrow['classId'];

//test ... which did not work !!!
echo $classrow['classId'];

        if ($ticketrow['eventTickets'] == "Yes")

    {
        for($counter=1;$counter<$numberOfTickets;$counter++)

        {
            $bookTicket = mysql_query("UPDATE unites SET ticketSold = 'Yes' WHERE businessreservationIdFk = '$eventId' AND classIDfk ='$choosedClass'") or die(mysql_error());  
            echo "ticket ". $counter . "  done !";


        }

    }

the script doesn’t fetch this syntax, and there is no errors showed on my page !

$classrow = mysql_fetch_array($selectClass) or die(mysql_error());

also , i tried to echo the variable $tickets after this syntax , it did not showed up, is there a problem to fetch more than mysql_query on the same script page ? tell me where do i go wrong here please .

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

    Don’t call die() in conjunction with a mysql_fetch_*() call. If there are no rows returned, mysql_fetch_array() returns FALSE, which triggers your die() and kills your script even though there was no error. Since you have already don error checking on $selectClass in the mysql_query() call, you know it has succeeded.

    // This query returned no rows, but was successful syntactically and functionally.
    $selectClass = mysql_query("SELECT classId FROM quotaclasses WHERE className = '$classes' AND eventFK = '$eventId'") or die (mysql_error());    
    

    Instead, test if rows were returned:

    if (mysql_num_rows($selectClass) > 0) {
      // Fetch and do other stuff
       $classrow = mysql_fetch_array($selectClass);
       $choosedClass = $classrow['classId'];
       // etc...
       // etc...
    }
    else {
      // Do whatever you need to do if no rows return
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little problem with a simple vbScript. The script has to run
I have a problem with following script. It generates a list of places which
i have problem on my php file upload script , i am trying to
I have an odd issue. I have one PHP script that is used for
I have problem with c# script who change user AD password, when try change
I have a problem with a script and I don't know how to handle
I have a problem with this script. At first I had the <div> s
I have a problem with a bash script. I have to use the operator
I have a problem while executing a SSIS script component. To be honest I
I have a problem with running lame encoder via shell_exec script in php. And

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.