I am trying to convert an old site to use mysqli rather than mysql.
Hit a bit of a stumberling block with this section of code
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }
  $theValue = function_exists("mysqli_real_escape_string") ? mysqli_real_escape_string($theValue) : mysqli_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;
}
}
I keep getting the errors
Warning:  mysqli_real_escape_string() expects exactly 2 parameters, 1 given in 
Warning:  mysqli_real_escape_string() expects exactly 2 parameters, 1 given in
If I add a connection like this
$theValue = function_exists("mysqli_real_escape_string") ? mysqli_real_escape_string($test,$theValue) : mysqli_escape_string($test,$theValue);
get the error
Warning:  mysqli_real_escape_string() expects parameter 1 to be mysqli, null given
Warning:  mysqli_real_escape_string() expects parameter 1 to be mysqli, null given
Could someone please tell me what I am doing wrong
Many thanks
 
     
     
    