You are pointing out a very important security issue which is very often forgotten:
Consider the same issue, but with UPDATE or DELETE SQL statements. Let's say that we have PHP code like:
$SQL="
delete from TABLE
where email='$email'
";
Now, what happens if the $email variable is received trough a form and the user places the following value in the email variable:
boris@jeltzin.net' OR 1=1
Bang:No more database, new web-developer.
The above PHP code should be re-written to:
$SQLemail=addslashes($email);
$SQL="
delete from TABLE
where email='$SQLemail'
";
Alternatively, the system administrator may turn on the "magic quotes GPC" PHP facillity. This would mean that all incoming (GET/POST/COOKIES) variables are automatically run through addslashes(). However, for people who know what they are doing, this may be very annoying and many people will simply not like to have PHP mess with their variables.
Note that addslashes() is not the only subtle security aspect that all developers should be aware of. Recently, there has been spotlight on cross-site scripting vulnerabilities (see the recent "Displaying Formatted User Input" article by Ying Zhang). So all PHP developers should also be aware of what the htmlspecialchars() function does.
Finally, the rawurlencode() function is often needed for bullet-proff web development, like when a <a href="http://somewhere/?var=SOMETHING_VARIABLE"> tag is dynamically created.
To answer your question:
Learn to use addslashes() or take a look at the (annoying!) "magic quotes GPC facility".