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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:38:14+00:00 2026-05-26T13:38:14+00:00

I’ve got a page that contains a fair few database queries, each appended with

  • 0

I’ve got a page that contains a fair few database queries, each appended with or die(). I’m loading this page every 1 second for testing, and on random page loads (it could take two, it could take five, or ten) die() is switched and an error given.

I broke down the script, and managed to isolate the particular offending query, which is:

$fetch = mysql_fetch_assoc($result) or die("Error 3:" . mysql_error());

This particular line is contained within:

if($size > 0) {
    $off_id = array();

    while($row = mysql_fetch_assoc($result)) {
        $off_id[] = $row['off_id'];
    }

    echo '<pre>';
    var_dump($off_id);
    echo '</pre>';

    $rand = rand(0,$size);
    $off_id = $off_id[$rand];

    $query = "UPDATE rotation_data SET hit_counter = hit_counter + 1 WHERE off_id = '{$off_id}'";
    $result = mysql_query($query) or die("Error 1:" . mysql_error());

    $query = "SELECT * FROM offer_data WHERE off_id = '{$off_id}'";
    $result = mysql_query($query) or die("Error 2:" . mysql_error()); 
    $fetch = mysql_fetch_assoc($result) or die("Error 3:" . mysql_error());
    $offer_url = $fetch['url']; $geo_target = $fetch['geo_target']; $blank = $fetch['blank'];

}

Things I noticed:

  • No mysql_error() is returned/printed. Only Error 3: is.
  • The $off_id array dumps correctly each and every time, so there’s always an $off_id to be used in the previous $result query, and if there wasn’t, that should trigger die() for the $result query instead.

I don’t really understand why this would occur on random page loads, and not all the time, as this perhaps points to it not being a syntax issue, but a load issue?

However, even if it’s a load issue, I don’t understand why that particular query would fail and trigger a die() while the others are fine.

Any help in understanding why this might be, and suggestions of what I could do to fix this would be greatly appreciated!

  • 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-05-26T13:38:15+00:00Added an answer on May 26, 2026 at 1:38 pm

    I am guessing that your query here returns no results:

    $query = "SELECT * FROM offer_data WHERE off_id = '{$off_id}'";
    

    The following statement will not return FALSE, just an empty result set into $result.

    // No results here this time...
    $result = mysql_query($query) or die("Error 2:" . mysql_error()); 
    

    And then you attempt to fetch a row from an empty result resource. This results in FALSE not because of error, but because there are no rows to fetch, and your short-circuit evaluation calls die().

    We cannot see where you are setting $size, but it’s possible that you are occasionally reading past the array bounds of $off_id by reaching a random value that is larger than that array.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into

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.