Update PHP function GetSQLValueString
PHP is not my area of expretise, so just some generic notes:


The function create a new MySQL connection on every call which could be a bottleneck in your application. You could use persistent connections with a p: prefix but others usually suggest PDO as a better alternative of database handling.
The $the prefix on most of the variables seem redundant (it doesn't add too much to them), I'd avoid it.
If you intended to return the original value when its not text, long, int etc. you should make it explicit with a default case inside the switch statement. If not, throw an exception in the default case and sign the error. (The Pragmatic Programmer: From Journeyman to Master by Andrew Hunt and David Thomas: Dead Programs Tell No Lies.)
case "text" and case "date" contains the same logic, you could use fall through there too.