cflores59 Posted February 14, 2011 Share Posted February 14, 2011 I'm a newbie and notice that all my .php pages (files, scripts--what are they called?) begin with <?php /* Change next two lines if using online*/ $db=".........."; $link = mysql_connect('localhost', ....................'); if (! $link) die(mysql_error()); mysql_select_db($db , $link) or die("Couldn't open $db: ".mysql_error()); and end with mysql_close($link); ?> Is this standard or should I leave it open til I'm finished and then close?????????????????? Altho I experimented with not closing & opening & it seemed that by doing so I couldn't access the next table I was after. Link to comment https://forums.phpfreaks.com/topic/227678-should-one-mysql_close-db-at-end-of-every-php-page-that-opens-it/ Share on other sites More sharing options...
Pikachu2000 Posted February 14, 2011 Share Posted February 14, 2011 You typically don't need to explicitly close the connection at all. php takes care of that at the termination of the script. Using mysql_close isn't usually necessary' date=' as non-persistent open links are automatically closed at the end of the script's execution. See also freeing resources.[/quote'] Link to comment https://forums.phpfreaks.com/topic/227678-should-one-mysql_close-db-at-end-of-every-php-page-that-opens-it/#findComment-1174290 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.