การ insert ตัวอักษรพิเศษเข้าไปใน mysql

<?php
//insert commant
error_reporting( E_ALL );
include("connect_db.php");

$text="insert into table (data1) values ('insert into table (f1,f2,f3) values ('v1','v2','v3')'";

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

  $insertSQL = sprintf("INSERT INTO command (`cid` ,`site`,`comm`) VALUES (%s, %s, %s)",
                       GetSQLValueString(NULL, "int"),
                       GetSQLValueString("1", "int"),
                       GetSQLValueString($text, "text"));

  $Result1 = mysql_query($insertSQL) or die(mysql_error());


if($Result1){echo "<br/>Ok";}else{echo "<br/>No";}
?>