The only problem with interpolating it into the SQL statement is that if it comes from an outside (that is, untrusted) source (as it seems in your examples), then anyone can maliciously or unintentionally include characters that mean things to SQL. For example, imagine someone putting something like this into $mailbox (presumably gotten from the CGI values): "test"; delete from bar;