1

This may or may not be a programming question.

This is regarding a question I asked earlier. You don't need to know about the earlier question for this but it might be relevant. I am not sure if this a memory or settings or ie or maybe db(highly unlikely) issue.

$table_name is actually a view, if it makes any difference. The database is MySQL. I have the following piece of code. For consistency I added die() at the end.

$query = mysql_query("SELECT * FROM $table_name") or die(mysql_error());

$query1 = mysql_query("SELECT * FROM $table_name") or die(mysql_error());

$query2 = mysql_query("SELECT * FROM $table_name") or die(mysql_error());

$query3 = mysql_query("SELECT * FROM $table_name") or die(mysql_error());

$query4 = mysql_query("SELECT * FROM $table_name") or die(mysql_error());

echo "End";
die();

This simple php page does not run in ie but works fine in chrome and firefox. I get "Internet Explorer cannot display the webpage" error. There is no error in the developer's tool console. The view has about 50,000 records.

However this piece of code runs fine. Another query should not make that big of a difference.

$query = mysql_query("SELECT * FROM $table_name") or die(mysql_error());

$query1 = mysql_query("SELECT * FROM $table_name") or die(mysql_error());

$query2 = mysql_query("SELECT * FROM $table_name") or die(mysql_error());

$query3 = mysql_query("SELECT * FROM $table_name") or die(mysql_error());
echo "End";
die();    

$query4 = mysql_query("SELECT * FROM $table_name") or die(mysql_error());

I thought maybe it's a large number of records for ie to handle(250k is small). So I tried this piece of code. The query has about 15 records each.

$query = mysql_query("SELECT * FROM $table_name WHERE col1 ='var'") or die(mysql_error());

$query1 = mysql_query("SELECT * FROM $table_name WHERE col1 ='var'") or die(mysql_error());

$query2 = mysql_query("SELECT * FROM $table_name WHERE col1 ='var'") or die(mysql_error());

$query3 = mysql_query("SELECT * FROM $table_name WHERE col1 ='var'") or die(mysql_error());

$query4 = mysql_query("SELECT * FROM $table_name WHERE col1 ='var'")or die(mysql_error());
echo "End";
die();

This one doesn't finish. I get the same error "Internet Explorer cannot display the webpage". However this works fine.

$query = mysql_query("SELECT * FROM $table_name WHERE col1 ='var'") or die(mysql_error());

$query1 = mysql_query("SELECT * FROM $table_name WHERE col1 ='var'") or die(mysql_error());

$query2 = mysql_query("SELECT * FROM $table_name WHERE col1 ='var'") or die(mysql_error());

$query3 = mysql_query("SELECT * FROM $table_name WHERE col1 ='var'") or die(mysql_error());
echo "End";
die();

$query4 = mysql_query("SELECT * FROM $table_name WHERE col1 ='var'") or die(mysql_error());

I am really baffled as to how Internet Explorer cannot handle 5 simple queries. Sometimes it doesn't even go to $query3, it can't go past $query2.

I have tested this locally - Win7, IE8. I have enough memory, hard drive space etc etc. Locally I am running PHP 5.3.5.

I also tested this on a unix based server on two different computers both running IE8. Again have enough memory, hard drive space etc etc. On the server, the PHP version is 5.25.

I did test this on a smaller table and it works fine. The table has 200 records that I generated randomly. But on a larger table(read view) it doesn't work.

I am really frustrated at this point with IE. Any insight/help to explain why it doesn't work if IE has any limitations or any way to fix it would be greatly appreciated.

Community
  • 1
  • 1
theking963
  • 2,223
  • 7
  • 28
  • 42
  • Not sure what the problem is (it's probably got nothing to do with IE, as your code is running on server side) but in general - you are not doing any error checking in your query. You *need* to do that after a `mysql_query()` call. Otherwise, your script will break with no error message if one of the queries fail. How to do this is outlined in the [manual on `mysql_query()`](http://php.net/mysql_query) or in this [reference question.](http://stackoverflow.com/questions/6198104/reference-what-is-a-perfect-code-sample-using-the-mysql-extension) – Pekka Dec 13 '11 at 18:34
  • I didn't add error checking here. But I have error checking in my actual code on the server. I can add it, it won't make any difference. Code updated. – theking963 Dec 13 '11 at 18:44
  • Try setting the content type to `text/plain`. You should get a better idea of what is going wrong. – Ed Heal Dec 13 '11 at 18:50
  • I did, still get the same error. What I am looking for here with `text/plain`? – theking963 Dec 13 '11 at 19:02

4 Answers4

0

This is not a problem on IE. IE can't display the webpage because the server didn't return the results (properly). Disable the "friendly messages" in your IE and you could (possibly) get a better message, maybe even some hints on what is the problem. You could also enclose everything in a try-catch and print the results, that might help as well. http://php.net/manual/en/language.exceptions.php

msb
  • 1
  • I did add it in a try catch block but I still don't get any error message. Just `Internet Explorer cannot display the webpage`.. – theking963 Dec 13 '11 at 18:52
  • things I would try: 1. comment the first query and leave the fifth (should work the same as when you don't have the fifth but have the first) 2. put the table name, instead of a variable 3. specify a single column 4. check for any limitation on number of simultaneous open connections to the DB (either in the server or in PHP) hope this helps... – msb Dec 13 '11 at 19:04
  • 1) Tried it, it works that way. 2) Makes no difference. 3) Even with single column ie `SELECT col1 from ..` it can't read all of them. 4) Number of possible simultaneous open connections is 250. Right now there are only 30. – theking963 Dec 13 '11 at 19:17
  • 5. print something between calls, just to make sure it goes that way (be sure not to be buffered) 6. retrieve the URL with wget, so I can see exactly what the server is returning. Do you have access to server logs? Your server is windows or linux? – msb Dec 13 '11 at 19:37
  • I just read your other thread. I'm guessing you're not calling this script directly, only through ajax, right? If so, you should try to access it directly, to isolate only the problematic part of all things involved. – msb Dec 13 '11 at 19:47
  • Also, if it works with firefox/chrome (which would be really odd), I would try one more thing: save the result from firefox and make the script print that result, without executing any queries, and check how IE behaves. – msb Dec 13 '11 at 19:49
  • This is another script I wrote to debug the previous issue. I am not using ajax or anything else here just php. It cannot be the code and/or server as it works in chrome and firefox, unless it's an IE centric settings. I had print statements between each query and it prints it out. For simplicity I removed it from the question. Locally it's Win 7, on the server it's UNIX. I will try the new idea. – theking963 Dec 13 '11 at 20:10
0

Just to clear things up, PHP runs on the server. IE and Firefox are browsers and do not execute any PHP (which is what's running the queries).

The PHP script your running is probably timing out on IE. Simply put, it's taking so long to render, IE thinks it's broken (and so will most users).

Consider using AJAX calls.

Saurav
  • 3,096
  • 3
  • 19
  • 12
  • I am using ajax calls. If you read the previous question that's where the error comes from. I am trying to debug that here. – theking963 Dec 13 '11 at 18:49
0

Likely you are hitting a maximum execution time when executing all the 5 queries,
and your script did not return a proper HTTP status
(likely is an error 500, you need to verify against your apache log)

However, the most deadly problem is because you are repeating same set of SQL for 5 times.
All query are returning same set of results, you can simply combine all 5 queries into one.

Once you combine the queries, do a benchmark on how long it takes to execute a query from view,
without knowing what exactly you have written for the view, I reluctant to say is safe.

ajreal
  • 46,720
  • 11
  • 89
  • 119
  • If I do in mysql it takes less than a second to run the query. IE times out in about 5-10 secs. – theking963 Dec 13 '11 at 18:52
  • Do you know the results from view is cached? However, if there is an update, the cache will get invalidated, and mysql have to compute all over again. Do you want to include your iterate for mysql result? (maybe you have include an infinite loop somewhere) – ajreal Dec 13 '11 at 18:54
  • Most likely it's being cached as I haven't updated/deleted/inserted anything since yesterday. Don't have any infinite loop. This is just a testing a code with this snippet. I did try to print the results but if I do that it doesn't go past 2-3 queries so not sure if it's a memory issue. – theking963 Dec 13 '11 at 18:58
  • You should really start combine same query, and test gain. – ajreal Dec 13 '11 at 19:02
0

The actual problem is that your page takes too long to load(due to the large query's) and IE will time out if its waiting longer then 1 min.

To fix you will need to edit the registry but that should not be necessary as no page should take longer then 1 min to load!

Lawrence Cherone
  • 46,049
  • 7
  • 62
  • 106
  • It times out in less than 10 secs. It doesn't even go over 30 secs. I am pretty sure the default is over 30 secs. – theking963 Dec 13 '11 at 18:54