case 'B':
case 'N':
case 'C':
case 'X':
if (is_null($val)) return 'null';
if (strlen($val)>0 &&
(strncmp($val,"'",1) != 0 || substr($val,strlen($val)-1,1) != "'")) {
return $db->qstr($val);
break;
}
// need to return something here.My preference is 'null'
Can you test this code ?