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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:42:22+00:00 2026-05-25T09:42:22+00:00

I really don’t understand what the issue is here, I’ve tried everything I can

  • 0

I really don’t understand what the issue is here, I’ve tried everything I can do diagnose the problem, and managed to isolate where I think the issue is being caused (see isolation below):

Here’s my full code:

include("db_conn.php");
$conn = mysql_connect($db_host, $db_user, $db_pass) or die(mysql_error()); mysql_select_db($db_name) or die(mysql_error());;

$timestamp = time();
$add_time = time()+(60*60);

$query = "UPDATE links SET timestamp = '$add_time', hit_counter = '0' WHERE timestamp >= '$timestamp' AND overflow = 'NO'";
$result = mysql_query($query) or die(mysql_error());

$query = "SELECT * FROM links WHERE timestamp <= '$timestamp' AND hit_counter <= max_hits AND overflow = 'NO'";
$result = mysql_query($query);

$size = mysql_num_rows($result) or die(mysql_error());

if($size == 0) {
    $query = "SELECT * FROM links WHERE overflow = 'YES'";
    $result = mysql_query($query) or die(mysql_error());

    $overflow = array();
    while($row = mysql_fetch_assoc($result)) {
        $overflow[] = $row['link'];
    }

    header("Location: http://www.google.com/?url=$overflow[0]");
}

$links = array();
$hits = array();

while($rows = mysql_fetch_assoc($result)) {
    $links[] = $rows['link'];
    $hits[] = $rows['hit_counter'];
}


$key = rand(0,$size);

$link = $links[$key];
$hit_counter = $hits[$key]+1;

$query = "UPDATE links SET hit_counter = '$hit_counter' WHERE link = '$link'";
$result = mysql_query($query) or die(mysql_error());*/

echo $link;
echo $hit_counter;

mysql_close($conn);

When the script is run, echo $link; which should be a randomly selected URL, displays nothing.

In order to diagnose the issue, I’ve been attempting to use echo "Hello World!";, gradually moving it up the script, any nothing is displayed until echo "Hello World!"; is placed before the initial MySQL query, which leads me to believe that the issue lies within there, even though no mysql_error()'s are being printed.

Also, I’ve tried to echo $size; on the line below $size = ... and that still displays nothing.

Isolation:

$query = "UPDATE links SET timestamp = '$add_time', hit_counter = '0' WHERE timestamp >= '$timestamp' AND overflow = 'NO'";
$result = mysql_query($query) or die(mysql_error());

$query = "SELECT * FROM links WHERE timestamp <= '$timestamp' AND hit_counter <= max_hits AND overflow = 'NO'";
$result = mysql_query($query);

$size = mysql_num_rows($result) or die(mysql_error());

Does anyone have any idea why this would cause the rest of the script to not run, yet return no errors?

Any help 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-25T09:42:22+00:00Added an answer on May 25, 2026 at 9:42 am

    I think the problem is in this line:

    $size = mysql_num_rows($result) or die(mysql_error());
    

    when the num_rows call returns 0, the interpreter will parse the die(mysql_error()) part even if there is no error at all.

    Lesson: It’s best to avoid ... or die() constructs. Do a proper check instead:

    $size = mysql_num_rows($result);
    
    if ($size === false) die(mysql_error()); // or, even better, trigger_error()
                                             // so mySQL errors aren't shown
                                             // in production
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I really don't know if it's a Netbeans issue but here's the problem: In
I have a homework problem that I really don't know how to start. Here
I've got a strange problem and really don't understand what's going on. I made
I really don't understand how to use SimpleXML in PHP. Here is an exemple
I really don't understand Javascript. In PHP, I can remove quotes like this: $tags_array
I really don't think this is a precision problem, the answer should be about
I really don't understand the fascination with XHTML strict. Inline JavaScript typically requires a
I really don't understand regular expressions and was wondering what the following regular expressions
I really don't understand what I'm doing wrong, but according to Adobe, this is
I really don't understand why do we need to create channel.html file, as mentioned

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.