Oh what a tangled web we have.
Lookup addslashes() in the php manual and read through the comments.
http://www.php.net/manual/en/function.addslashes.php
You will find a big discussion on this whole slash thing.
The bottom line is that you don't need to use addslashes for mysql. It turns out that mysql supports a propierity extension to it's sql processor which does support slashes. That's why your existing code works. But, MSSQL does not.
I have used sql interfaces for many years. When I started in php I just automatically doubled the quotes and never worried about this whole slash problem as far as the database was concerned.
Next, follow the majic_quotes_gpc link. Basically, the php developers decided to make things 'easier' for regular developers by automatically slashing data from GET/POST/COOKIES/ENV etc. That's why you end up getting slashes when pulling data from say $_POST. And that's why I use stripslashes to get rid of them. You should actually check a global variable before using stripslashes() since it's possible to turn off this majic quoting. The manual has examples.
When selecting data from the database, no automatic quoting or slashing is done. Yeah for small favors. As far as I know, you don't have to do anything special.
The final piece of the puzzle comes in when sending a string to your html form. Certain characters (besides just quotes and double quotes) have special meaning in html and must be turned into entities. The htmlspecialchars() function accomplishes this.
So, to repeat the bottom line, I don't think you need to use addslashes at all when interfacing to a database.
I don't pretend to have written dozens of php applications on multiple platforms. So there may be other cases where you do need addslashes(). But I have implemented a few and so far at least, whatever the user types into one of my forms ends up getting stored correctly in mysql.