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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:52:07+00:00 2026-05-13T11:52:07+00:00

Can anyone of you help me understand the behavior I get when visiting this

  • 0

Can anyone of you help me understand the behavior I get when visiting this page?

<html>

    <body>

    <?php
        $liendb = mysql_connect("localhost","","");

        mysql_select_db ("test");
        for($i = 0; $i < 418; ++$i)
        {
            echo("Any old text<br />");
        }


        $resultatSQL = mysql_query("SELECT uid FROM nombres ORDER BY uid");

        while($tab = mysql_fetch_array($resultatSQL, MYSQL_ASSOC))

        {
            echo("<p>".$tab['uid']."</p>");
            echo("<br />\n");

        }

        mysql_close();

    ?>

    </body>
</html>

I exported the mysql table this example is based on so that we can work on the same table.. Here it is:

-- phpMyAdmin SQL Dump
-- version 3.2.0.1
-- http://www.phpmyadmin.net
--
-- Servidor: localhost
-- Tiempo de generación: 06-01-2010 a las 21:49:50
-- Versión del servidor: 5.1.37
-- Versión de PHP: 5.3.0

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Base de datos: `test`
--

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `nombres`
--

CREATE TABLE IF NOT EXISTS `nombres` (
  `uid` int(10) unsigned NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`uid`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=43 ;

--
-- Volcar la base de datos para la tabla `nombres`
--

INSERT INTO `nombres` (`uid`) VALUES
(1),
(2),
(3),
(4),
(5),
(6),
(7),
(8),
(9),
(10),
(11),
(12),
(13),
(14),
(15),
(16),
(17),
(18),
(19),
(20),
(21),
(22),
(23),
(24),
(25),
(26),
(27),
(28),
(29),
(30),
(31),
(32),
(33),
(34),
(35),
(36),
(37),
(38),
(39),
(40),
(41),
(42);

In theory, I believe this page should print 418 lines of “Any old text”, and then print all entries of table “nombres”, so numbers 1 to 42. In practice, it does. But if I change that magic number, 418, problems happen.

If I use a number smaller than 418, firefox offers to download the page instead of just showing it to me.. If I do download it, I get a blank file..

If I use a number larger than 418, I don’t get all the entries to table “nombres”. For example, when I use 419, I get only numbers 1 to 41. When I use 420, I get only numbers 1 to 40. And so on until 454, where I only get number 1. The rest of the page, everything following the numbers, is truncated, including the closing body and html tags.

If I use 455 or more, I don’t get any numbers at all!

My questions:

Is anyone else able to reproduce this behavior?
How could you explain this behavior?

The server I use is apache (actually xampp)
I printed phpinfo() and asked firefox to save the resulting page.. Here it is, compressed.
http://www.angelfire.com/planet/shawninder/phpinfo.zip

  • 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-13T11:52:08+00:00Added an answer on May 13, 2026 at 11:52 am

    Judging from your code, maybe the problems lies in the mysql connection. You should always check if the mysql connection is successfully or failed, before using it. Try to rewrite your code like this:

    <html>
        <body>
        <?php
            //open connection
            $liendb = mysql_connect("localhost","","");
            if ( ! $liendb )
            {
              die('Could not connect: ' . mysql_error());
            }
    
            //select database
            $select_db = mysql_select_db ("test", $liendb);
            if ( ! $select_db )
            {
              die ("Failed to do select the database: ' . mysql_error());
            }
    
            //print 'magic' lines
            for($i = 0; $i < 418; ++$i)
            {
                echo("Any old text<br />");
            }
    
            //get table's content
            $resultatSQL = mysql_query("SELECT uid FROM nombres ORDER BY uid", $liendb);
            if ( ! $resultatSQL )
            {
              die('Invalid query: ' . mysql_error());
            }
    
            //process table content
            while($tab = mysql_fetch_array($resultatSQL, MYSQL_ASSOC))
            {
                echo("<p>".$tab['uid']."</p>");
                echo("<br />\n");
            }
            mysql_close($liendb);
        ?>
        </body>
    </html>
    

    With this code, if any error related with mysql connection happened, then you will got the error message, instead of it silently fail. Maybe it will make the php module in apache crash, so the process died prematurely and apache then send the incomplete page as a file to download, instead of displaying it as a web page.

    Let me know the result in your computer.

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

Sidebar

Related Questions

Can anyone help me understand this query? The mktpgmvhclxref.mktpgmvhclxrefId.mktgPgm part mostly. Generally it is
Can anyone help me understand why this is not working? <div id=css-check class=css-check tool-tip
This is driving me insane, can anyone help me understand why the following statements
Can anyone help me understand how I should read this stacktrace? Task-Thread-for-com.mchange.v2.async.ThreadPerTaskAsynchronousRunner@488cf1f1 daemon prio=6
Can anyone help me understand what is going on here? Jenkins has been working
Hey can anyone help me understand how to do an edit method for my
Can anyone please help me to understand how should i access json data in
I wonder if anyone can help me to understand where I could be going
Can anyone help - this is driving me mad. I am calling a mysql
Can anyone help me to get good WordPress interview questions and answers. Any link

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.