imarockstar Posted July 10, 2009 Share Posted July 10, 2009 I have a page that returns a crap load of data but whenever I run this query .. .the page hangs .... should I OPEN and CLOSE the DB connection for each time i run a query ?? here is the page that is hanging .. <? session_start(); if (isset($_SESSION['membersInfo']['username'])) { $pimp = "hellya"; } else header("Location: index.php"); ?> <?php include("includes/head.php"); ?> <?php include("includes/header.php"); ?> <!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ content start --> <?php $userid = $_POST['userid']; $sql="SELECT * FROM users WHERE userid = '$userid' "; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){; ?> <? echo $rows['fname']; ?> <? echo $rows['lname']; ?> has answered the following portions of the application . <br> Click on the set of questions to view the answer . <?php } ?> <?php $sql="SELECT * FROM gq_answers WHERE userid = '$userid' "; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==1){ echo "General Questions"; }; ?> <!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ content end --> <?php include("includes/footer.php"); ?> when i take out this batch of code .. it loads fine ... <?php $sql="SELECT * FROM gq_answers WHERE userid = '$userid' "; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==1){ echo "General Questions"; }; ?> Link to comment https://forums.phpfreaks.com/topic/165495-solved-page-taking-forever-to-display-i-think-i-have-a-php-db-error/ Share on other sites More sharing options...
Maq Posted July 10, 2009 Share Posted July 10, 2009 That code shouldn't cause that kind of lag. Check your MySQL and Apache log files. Link to comment https://forums.phpfreaks.com/topic/165495-solved-page-taking-forever-to-display-i-think-i-have-a-php-db-error/#findComment-872859 Share on other sites More sharing options...
rhodesa Posted July 10, 2009 Share Posted July 10, 2009 is that block of code inside the while loop? if so, you need to use a different variable name for $result for your query that is inside the loop. otherwise there will be conflicts Link to comment https://forums.phpfreaks.com/topic/165495-solved-page-taking-forever-to-display-i-think-i-have-a-php-db-error/#findComment-872861 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.