PHP - GetSQLValueString function

后端 未结 4 385
臣服心动
臣服心动 2020-12-04 02:13

I see a function GetSQLValueString and I don\'t know what is it dealing with, could someone give me some idea?
Thanks you

function GetSQLValueString($t         


        
4条回答
  •  一整个雨季
    2020-12-04 02:57

    I guess your problem is related to the mysqli_ issue. You need to change all mysql_ to mysqli_ and add the connection to the database as first parameter. In my case the connection to the database is $conn_vote. Be aware that I added $conn as function's parameter :

     function GetSQLValueString($conn_vote, $theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
        {
          $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
    
          $theValue = function_exists("mysqli_real_escape_string") ? mysqli_real_escape_string($conn_vote, $theValue) : mysqli_escape_string($conn_vote, $theValue);`enter code here`
    
          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;
        }
        } 
    

    `

提交回复
热议问题