limitphp Posted November 6, 2008 Share Posted November 6, 2008 In my code I have: a query and a result, and then I grab everything I need from the database. Later on down the page, I have to do another query, etc. Do I need to close the database connection or anything before I start the next query? in other words, can I have: $query = "some query statement"; $result = mysql_query($query); $data = mysql_fetch_assoc($result); . . . $query = "some other query statement'"; $result = mysql_query($query); $data = mysql_fetch_assoc($result); Can both variables be called $query, or do I need to start a new name for the next query, like $query2, $result2, $data2? Quote Link to comment https://forums.phpfreaks.com/topic/131645-solved-php-close-connection-after-every-query/ Share on other sites More sharing options...
Maq Posted November 6, 2008 Share Posted November 6, 2008 Do I need to close the database connection or anything before I start the next query? No. Can both variables be called $query, or do I need to start a new name for the next query, like $query2, $result2, $data2? I'm almost positive you can keep the variable names the same because you're reassigning the values. I would rename them because this could cause issues and it's better to assign descriptive names, just like any other variable, so you can refer to them later. Quote Link to comment https://forums.phpfreaks.com/topic/131645-solved-php-close-connection-after-every-query/#findComment-683758 Share on other sites More sharing options...
limitphp Posted November 6, 2008 Author Share Posted November 6, 2008 thanks. Quote Link to comment https://forums.phpfreaks.com/topic/131645-solved-php-close-connection-after-every-query/#findComment-683771 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.