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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:34:30+00:00 2026-06-15T15:34:30+00:00

I have a function that will take an id and with that find out

  • 0

I have a function that will take an id and with that find out other information in the database relating to it spread among 3 tables. It then compares this to a csv file which at most times is cpu intensive. Running this once with one id takes approx 8 to 10 sec at most but I have been asked to have it run automatically across a varing number of ids in the database. To do this I created an array of the ids that match the criteria in the database at any point and then run a ‘while’ statement to repeat the function for each element in the array but it gets as far as maybe 4 of them and I get the following error:

Server error!

The server encountered an internal error and was unable to complete
your request. Either the server is overloaded or there was an error in
a CGI script.

If you think this is a server error, please contact the webmaster.

Error 500

I’ll admit that my code could be much much cleaner as I’m still learning as I go but the real bottle neck appears to be reading the csv which is a report which size changes each day. I have tried different combinations and the best result is (please don’t chastise me for this as I know it is stupid but the other ways haven’t works as of yet) to run the code as follows:

$eventArray = eventArray($venueId);
$totalEvents = count($eventArray);

for($i=0; $i<$totalEvents; $i++)
    {
        $eventId = $eventArray[$i];
        echo $eventId;
        echo $datename = getEventDetails($eventId, $zone);
            // date of event
        echo $eventDate = $datename['eventDate'];
            // vs team
        echo $eventName = $datename['eventName'];

        $file_handle = fopen("data/rohm/sales/today.csv", "r");
        while (!feof($file_handle) )
            {
                $line_of_text = fgetcsv($file_handle, 200);
                include('finance_logic.php');
            }
        fclose($file_handle);
    }

Yes, it is repeating the reading of the csv every time but I couldn’t get it to function at all any other way so if this is the issue I would really appreciate some guidence on dealing with the csv better. Incase it is relevent the code it ‘finance_logic.php’ is listed below:

if($line_of_text[0] == "Event: $eventName ")
{
    $f = 1;
    $ticketTotalSet = "no";
    $killSet = 'no';
    // default totals zero
    $totalHolds = 0;
    $totalKills = 0;
    $ticketSold = 0;
    $ticketPrice = 0;
    $totalCap = 0;
}
if($f == 1 && $line_of_text[0] == "$eventDate")
    {
        $f = 2;
    }
    if($f == 2 && $line_of_text[0] == "Holds")
        {
            $f = 3;
            while($line_of_text[$col] !== "Face Value Amt")
                {
                    $col++;
                }
        }
        if($f == 3 && $line_of_text[0] !== "Face Value Amt")
            {
                if($f == 3 && $line_of_text[0] == "*: Kill")
                    {
                        $totalKills = $line_of_text[$col];
                    }
                $holdsArray[] = $line_of_text[$col];
            }
        if($f == 3 && $line_of_text[0] == "--")
            {
                $f = 4;
            }
            if($f == 4 && $line_of_text[0] == "Capacity")
                {
                    $totalCap = $line_of_text[$col];
                    $f = 5;
                }   
                if($f == 5 && $line_of_text[0] == "Abbreviated Performance Totals")
                    {
                        $f = 6;
                    }
                    if($f == 6 && $line_of_text[0] == "$eventName")
                        {
                            // change when 1 ticket exists
                            $ticketTotalSet = "yes";
                            // set season tickets
                            include("financial/seasontickets/$orgShortName.php");
                            // all non season are single tickets
                            if(!isset($category))
                                {
                                    $category = 'single';
                                }
                            $ticketName = $line_of_text[2];
                            $ticketSold = $line_of_text[3];
                            $ticketPrice = $line_of_text[4];
                            addTicketType($eventId, $ticketName, $category, $ticketSold, $ticketPrice);
                            unset($category);
                        }
                        if($f == 6 && $ticketTotalSet == "yes" && $line_of_text[0] !== "$eventName")
                            {
                                $totalHolds = (array_sum($holdsArray) - $totalKills);
                                // add cap, holds and kills
                                addKillsHoldsCap($eventId, $totalCap, $eventId, $totalHolds, $totalKills);
                                // reset everything
                                $f = 0;
                                $ticketTotalSet = "no";
                                echo "$eventName updated!";
                            }

Thanks in advance!

p.s. The reason the report is called each time is so that the ‘eventName’ and ‘eventDate’ are searched for with the ‘finance_logic.php’. Obviously if this was set with all event names and dates already it would take one search of the report to find them all but I’m not sure how I could do this dynamically. Any suggestions would be welcome as I’m sure there is something out there that I just haven’t learnt yet.

  • 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-15T15:34:32+00:00Added an answer on June 15, 2026 at 3:34 pm

    I have some heavy script i use with localhost sometimes and if i don’t add anything they will just time out.

    A simple solution is to limit the number of execution of your function, then reload the page, then restart where you stopped.

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

Sidebar

Related Questions

I have a function that will take a range of values, which need to
I have a function that will parse some data coming in. My problem is
I have a function that will allow me to edit the manager property of
I currently have a function that will create X tasks of a function based
I have created a function that will return the string path from my DB.
I have a javascript function that will show the image you're about to upload
I want to have a jquery function that will be activated when any checkbox
I have a binary search function that will search for a word in an
I have problem with fancybox. I want to write a function that will run
I have DLL and application that will call some function in this dll. For

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.