Ok... example ...
If magic_quotes are not on and your user logging in has a nick of:
Bert's Store
$sql = "SELECT DISTINCT * FROM `users` WHERE `user` = '$name'";
.. would be read as ...
$sql = "SELECT DISTINCT * FROM `users` WHERE `user` = 'Bert'";
See how the statement terminates?? That because of the paranthesis.
So if it's escaped (either by using the addslashes() function, mysql_escape_string() or having magic_quotes_gpc='On' in your php.ini ...
$sql = "SELECT DISTINCT * FROM `users` WHERE `user` = 'Bert\'s Store'";
See the \ ?? EDIT:.. no you won't because Vbulletin sucks. But.. it's there trust me..
That's escaped the extra ' that would cut off the statement.
There is alot more to this than just that however. So perhaps I can turn your attention to:
http://www.zend.com/zend/tut/using-strings.php
http://uk.php.net/get-magic-quotes-gpc
http://uk.php.net/addslashes
http://uk.php.net/manual/en/function.stripslashes.php