Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Konrad Pilch
Konrad Pilch
2,435 Points

PHP When do we use? mysql_close($connection)

HI,

When do we use mysql_close($connection) ?

I know its to close connection but when? : p

If somebody will attack a file and if some code is executed thill will come? : p or something.

2 Answers

you will want to use it at the footer of any page were you connect to the db.

Andrew Shook
Andrew Shook
31,709 Points

Never, because you shouldn't be using any of the mysql_****** functions anymore. They were deprecated in PHP 5.5 and if you use them now it will make upgrading your app more difficult in the future.

Konrad Pilch
Konrad Pilch
2,435 Points

Well, i know about mysqli but i just copied it and if we add and mysqli_close($connection) it should still work right . But when do we use this code? or what it did serve before? i mean