|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-05-11 14:08 UTC] ralphyz at gmail dot com
Description:
------------
I get "The Page Cannot Be Displayed" error message when there are 3 print statements in a row which display the contents of an array (which only has 1 column, and 3 rows). When I comment out any of the three print statements, the page displays without a problem.
I tested this code on Ubuntu - and it works without a problem.
Also commenting out any of the following three lines makes this work without a problem:
print ("id: $id <BR>");
print ("name:" . $name . "<BR>");
print ("description:" . $description . "<BR>");
If I comment out any of those lines, but replace the "IF" statement with a "FOR" statement to run through all my records ($num_rows = 31), I get the same error (The Page Cannot Be Displayed).
The print statements with "got here" in them seem to have no negative effect on the script.
Reproduce code:
---------------
<?php
$DBHost = "x.x.x.x"; // IP-address of MySQL server
$DBLogin = "username"; // Username of MySQL user
$DBPassword = "password"; // Password of MySQL user
$DBDatabase = "database"; // Name of database
$db_error = "";
$sql = "select A, B, C from employee";
$data_set = get_data($sql);
$num_rows = mysql_num_rows($data_set);
if($num_rows > 0)
{
$row = mysql_fetch_array($data_set, MYSQL_NUM);
$id = $row[0];
$name = $row[1];
$description = $row[2];
print ("id: $id <BR>");
print ("name:" . $name . "<BR>");
print ("description:" . $description . "<BR>");
print ("got here");
print ("got here");
print ("got here");
print ("got here");
print ("got here");
print ("got here");
print ("got here");
print ("got here");
print ("got here");
print ("got here");
}
function get_data($sql)
{
global $DBHost, $DBLogin, $DBPassword, $DBDatabase, $db_error;
if(!mysql_connect("$DBHost", "$DBLogin", "$DBPassword"))
{
return "$db_error";
}
else
{
mysql_select_db("$DBDatabase");
return mysql_query($sql);
}
}
?>
Expected result:
----------------
This should display:
1
John Smith
Staff
got heregot heregot heregot heregot heregot heregot heregot heregot heregot here
Actual result:
--------------
The page cannot be displayed
There is a problem with the page you are trying to reach and it cannot be displayed.
--------------------------------------------------------------------------------
Please try the following:
Open the x.x.x.x home page, and then look for links to the information you want.
Click the Refresh button, or try again later.
Click Search to look for information on the Internet.
You can also see a list of related sites.
HTTP 500 - Internal server error
Internet Explorer
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 13:00:02 2025 UTC |
There are no errors in the log file. The following lines: print ("id: $id <BR>"); print ("name:" . $name . "<BR>"); print ("description:" . $description . "<BR>"); All work individually (two others are commented out), or in pairs (one other is commented out). I get the error when all three are active (none of the three commented out). They also work if I do this: print ("id: $id <BR>name: $name<BR>description: $description"); It just won't work if I have three separate lines. No other code gives me an error.