get_magic_quotes_gpc() is a function that checks a PHP configuration setting MAGIC QUOTES.
If magic quotes is set to ON in the configuration, then the server automatically helps you escape your text fields by adding slashes to your GET/POST variables, so you can put it right in your database.
i.e. This would break, quotes don't match up.
$POST[compname] = "Joe's Crab Shack";
$query = "SELECT * FROM mytable where company = '$POST[compname]'"
because it gets parsed to
$query = "SELECT * FROM mytable where company = 'Joe's Crab Shack'"
When MAGIC QUOTES is on,
the system automatically addslashes for you so that
$_POST[compname] = "Joe\'s Crab Shack"
If MAGIC QUOTES is off, you have to do it yourself by applying the addslashes() function.
As for the sprintf() function
'%s' is a placeholder.
The sprintf function saids, put the value of $colname_Recordset1
where %s is. (Or replace %s with the value of $colname_Recordset1)
I hope this helps a little, here's the supporting documentation:
http://us3.php.net/manual/en/function.get-magic-quotes-gpc.php
http://us3.php.net/manual/en/function.sprintf.php