lonewolf217 Posted June 23, 2008 Share Posted June 23, 2008 I have a generic question that may or may not have a simple answer. If code samples are required, I can provide them. I originally had a small site for a project at work that was coded in asp. When I loaded data or performed searches, data was loaded instantly and I can quickly switch between pages with no delay. I have since started rewriting the pages in php with nearly exactly the same functionality, just in the different code. Now when I load a page in .php the data displays almost instantly like before, but the status bar still shows "Page is loading...." for several seconds. If I try to changes pages again while this message is there, the behavior is not as it should be. If I wait for the page to finish loading, then the page changes are processed correctly. I do not know what I did differently between asp and php but since All I am doing is doing one SQL query and displaying the results on the page the load time is not intensive (VERY small data sets right now). Is there a general reason why this may happen with php, or would you need code samples to compare to try to find what I did wrong. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/111552-generic-question-why-does-it-take-longer-to-load-a-page-in-php-than-in-asp/ Share on other sites More sharing options...
.josh Posted June 23, 2008 Share Posted June 23, 2008 one simple query shouldn't be yielding several second delays like that. You'll have to post some code. Quote Link to comment https://forums.phpfreaks.com/topic/111552-generic-question-why-does-it-take-longer-to-load-a-page-in-php-than-in-asp/#findComment-572562 Share on other sites More sharing options...
lonewolf217 Posted June 23, 2008 Author Share Posted June 23, 2008 the query itself doesn't, as the data is displayed immidiately on the page. it is doing something after displaying the data that I do not know what it is, because I have no code to process after displaying the table. I will post code snippets shortly Quote Link to comment https://forums.phpfreaks.com/topic/111552-generic-question-why-does-it-take-longer-to-load-a-page-in-php-than-in-asp/#findComment-572566 Share on other sites More sharing options...
lonewolf217 Posted June 23, 2008 Author Share Posted June 23, 2008 This is a simple example, just a stupidly simple page to pull out URL bookmarks that have been saved in the database This is a page in .asp <% Dim rs Dim strSQL Dim adoCon Set adoCon = Server.CreateObject("ADODB.Connection") AdoCon.Open 'Create an ADO recordset object Set rs = Server.CreateObject("ADODB.Recordset") 'Initialize the strSQL variable with a SQL statement to query the database strSQL = "Select * FROM weblinks ORDER BY Abstract" 'open the record set with the sql query rs.Open strSQL, adoCon 'loop through the recordset Response.Write("<center><table border=0>") Do While not rs.EOF Response.Write("<tr><td>") Response.Write("<a href=" & rs("URL") & " target=""_new"">" & rs("Abstract") & "</a>") Response.Write("</td><td>") Response.Write(rs("Comment")) Response.Write("</td></tr>") rs.MoveNext Loop Response.Write("</table></center>") rs.Close Set rs = Nothing Set adoCon = nothing %> compared to the same functionality in php <?php if($connection = mssql_connect($myServer,$myUser,$myPass)){ mssql_select_db($myDB,$connection); if($sql = mssql_query("Select * FROM weblinks ORDER BY Abstract")) { echo "<center><table>"; while($row = mssql_fetch_array($sql)) { echo "<TR><TD>"; echo "<a href=" .$row[2] . " target=_new>" . $row[3] . "</a>"; echo "</TD><TD>"; echo $row[4]; echo "</TD></TR>"; } echo "</TABLE></center>"; } else { echo "Error: " . mysql_error(); } } else{ echo "Error: " . mysql_error(); } ?> and as I said before, the data is loaded nearly instantly and displayed in my table, but the status of the page is still shown as loading and says "Transferring data from <server>" for a few seconds even after the data is displayed and I am pretty confused as to why this is happening. Do I have to close a connection, uninitialize variables or something ? Quote Link to comment https://forums.phpfreaks.com/topic/111552-generic-question-why-does-it-take-longer-to-load-a-page-in-php-than-in-asp/#findComment-572579 Share on other sites More sharing options...
.josh Posted June 23, 2008 Share Posted June 23, 2008 hmm well you could manually close the connection with mysql_close($connection); but php automatically does that when the script is done. Same with the vars. I mean, php is a server-side script same as asp; stuff won't be sent off to the client until the script is done executing, so I don't really think that will make a difference. ... Quote Link to comment https://forums.phpfreaks.com/topic/111552-generic-question-why-does-it-take-longer-to-load-a-page-in-php-than-in-asp/#findComment-572624 Share on other sites More sharing options...
lonewolf217 Posted June 24, 2008 Author Share Posted June 24, 2008 might anyone have a response on this one ? its not really a huge issue, just a minor annoyance at the extra few seconds of load time Quote Link to comment https://forums.phpfreaks.com/topic/111552-generic-question-why-does-it-take-longer-to-load-a-page-in-php-than-in-asp/#findComment-573407 Share on other sites More sharing options...
discomatt Posted June 24, 2008 Share Posted June 24, 2008 But there isn't actually any 'extra load time'.. this seems like a potential browser issue. Is this an isolated problem, or are other systems/browsers seeing this 'extra load'? Quote Link to comment https://forums.phpfreaks.com/topic/111552-generic-question-why-does-it-take-longer-to-load-a-page-in-php-than-in-asp/#findComment-573438 Share on other sites More sharing options...
wildteen88 Posted June 24, 2008 Share Posted June 24, 2008 It most probably to do with how your server is configured rather than PHP. As CV said if PHP was still processing the script you'll just get a blank page. PHP does not outpot data a bit a time. The following script proves this: echo 'Hello'; sleep('2'); // sleep for 2 secounds echo ' world'; If you ran that PHP will outut 'Hello world' after two seconds has passed. It wont output Hello and then world 2 seconds after. Quote Link to comment https://forums.phpfreaks.com/topic/111552-generic-question-why-does-it-take-longer-to-load-a-page-in-php-than-in-asp/#findComment-573444 Share on other sites More sharing options...
lonewolf217 Posted June 24, 2008 Author Share Posted June 24, 2008 thanks for the suggestion. is it a bad configuration in my php.ini file ? Anything you could point me in the right direction of ? Quote Link to comment https://forums.phpfreaks.com/topic/111552-generic-question-why-does-it-take-longer-to-load-a-page-in-php-than-in-asp/#findComment-573446 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.