How to modify the php version if it is too low?

I made a small project in the local localhost environment, but I reported an error when I put it on the network server. I checked on the Internet and found that mysql_connect has been abandoned by the high version of php. I am just a front-end rookie who has reported a mistake and asked his seniors to help change the following sql file for the project package

.

https://pan.baidu.com/s/1e7Kx.

<?php
header("Content-type: text/html;charset=utf-8");//
//1
$conn=@mysql_connect("localhost","root","0123456zp");
if(!$conn){
    //mysql_error()mysql
    die("".mysql_error());
}else{
    //echo "<br/>";
}
//2
@mysql_select_db("caiwu");
//3
mysql_query("set names utf8");//utf8utf8--

$draw = $_GET["draw"]; //
//
$order_column = $_GET["order"]["0"]["column"]; // 
$order_dir= $_GET["order"]["0"]["dir"]; // ase desc 
//sql
$orderSql = "";
if(isset($order_column)){
    $i = intval($order_column);
    switch($i){
        case 0;$orderSql = " order by id ".$order_dir;break;
        case 1;$orderSql = " order by kh ".$order_dir;break;
        case 2;$orderSql = " order by kj ".$order_dir;break;
        case 3;$orderSql = " order by cpx ".$order_dir;break;
        case 4;$orderSql = " order by zhd ".$order_dir;break;
        case 5;$orderSql = " order by afzhd ".$order_dir;break;
        case 6;$orderSql = " order by afxjd ".$order_dir;break;
        case 7;$orderSql = " order by zxrq ".$order_dir;break;
        case 8;$orderSql = " order by xs ".$order_dir;break;
        case 9;$orderSql = " order by crrq ".$order_dir;break;
        case 10;$orderSql = " order by skr ".$order_dir;break;
        case 11;$orderSql = " order by skzh ".$order_dir;break;
        default;$orderSql = "";
    }
}

//
$start = $_GET["start"];//
$length = $_GET["length"];//
$limitSql = "";
$limitFlag = isset($_GET["start"]) && $length != -1 ;
if ($limitFlag ) {
    $limitSql = " LIMIT ".intval($start).", ".intval($length);
}

//sql
$sumSql = "SELECT count(id) as sum FROM financialdata";
// 
$recordsFiltered = 0;
// 
$recordsTotal = 0;
$recordsTotalResult = mysql_query($sumSql,$conn);
while($row=mysql_fetch_assoc($recordsTotalResult)){
    $recordsTotal = $row["sum"];
}
////sql
$search = $_GET["search"]["value"];//
// 
$j = 1;
$search_arr =array();
$colSearchSql="";
for($j=0;$j<6;$jPP){
    $colSearchable = $_GET["columns"][$j]["searchable"];
    $colSearchVal = $_GET["columns"][$j]["search"]["value"];
    if(strlen($colSearchVal)>0 && $colSearchable == "true" ){
        switch ($j) {
            case 0: $colSearchVal = "id LIKE "%".$colSearchVal."%"";
                array_push($search_arr,$colSearchVal);
                break;
            case 1: $colSearchVal = "kh LIKE "%".$colSearchVal."%"";
                array_push($search_arr,$colSearchVal);
                break;
            case 2: $colSearchVal = "kj LIKE "%".$colSearchVal."%"";
                array_push($search_arr,$colSearchVal);
                break;
            case 3: $colSearchVal = "cpx LIKE "%".$colSearchVal."%"";
                array_push($search_arr,$colSearchVal);
                break;
            case 4: $colSearchVal = "zhd LIKE "%".$colSearchVal."%"";
                array_push($search_arr,$colSearchVal);
                break;
            case 5: $colSearchVal = "afzhd LIKE "%".$colSearchVal."%"";
                array_push($search_arr,$colSearchVal);
                break;
            case 6: $colSearchVal = "afxjd LIKE "%".$colSearchVal."%"";
                array_push($search_arr,$colSearchVal);
                break;
            case 7: $colSearchVal = "zxrq LIKE "%".$colSearchVal."%"";
                array_push($search_arr,$colSearchVal);
                break;
            case 8: $colSearchVal = "xs LIKE "%".$colSearchVal."%"";
                array_push($search_arr,$colSearchVal);
                break;
            case 9: $colSearchVal = "crrq LIKE "%".$colSearchVal."%"";
                array_push($search_arr,$colSearchVal);
                break;
            case 10: $colSearchVal = "skr LIKE "%".$colSearchVal."%"";
                array_push($search_arr,$colSearchVal);
                break;
            case 11: $colSearchVal = "skzh LIKE "%".$colSearchVal."%"";
                array_push($search_arr,$colSearchVal);
                break;
            default:
                -sharp code...
                break;
        }
    }
}
if(empty($search_arr) == false){
    $colSearchSql = " WHERE ".implode(" AND ",$search_arr);
}
// sql
// $zSearchSql =" where teacher_id || teacher_name || teacher_password || teacher_email || teacher_date || teacher_note LIKE "%".$search."%"";
$zSearchSql = " id LIKE "%".$search."%" OR kh LIKE "%".$search."%" OR kj LIKE "%".$search."%" OR cpx LIKE "%".$search."%" OR zhd LIKE "%".$search."%" OR afzhd LIKE "%".$search."%"OR afxjd LIKE "%".$search."%"OR zxrq LIKE "%".$search."%"OR xs LIKE "%".$search."%"OR crrq LIKE "%".$search."%"OR skr LIKE "%".$search."%"OR skzh LIKE "%".$search."%"";
// SQL
$sumSearchSql = "";
if(strlen($colSearchSql)>0 && strlen($search)>0){
    $sumSearchSql = $colSearchSql." AND (".$zSearchSql.")";
}else if(strlen($colSearchSql)>0 && strlen($search)==0){
    $sumSearchSql = $colSearchSql;
}else if(strlen($colSearchSql)==0 && strlen($search)>0){
    $sumSearchSql = " WHERE ".$zSearchSql;
}else{
    $sumSearchSql = "";
}
if(strlen($sumSearchSql)>0){
    $recordsFilteredResult = mysql_query($sumSql.$sumSearchSql);
    while ($row = mysql_fetch_assoc($recordsFilteredResult)) {
        $recordsFiltered =  $row["sum"];
    }
}else{
    $recordsFiltered = $recordsTotal;
}
// query data
$sql="";
$totalResultSql = "SELECT * FROM financialdata";
$infos = array();
// SQL
$sql=$totalResultSql.$sumSearchSql.$orderSql.$limitSql;
$dataResult = mysql_query($sql,$conn);
while ($row = mysql_fetch_assoc($dataResult)) {
    // $obj = array($row["teacher_id"], $row["teacher_name"], $row["teacher_password"], $row["teacher_email"], $row["teacher_date"], $row["teacher_note"]);
    // array_push($infos,$obj);
    array_push($infos,$row);
}
// return data
echo json_encode(array(
    "draw" => $draw,
    "recordsTotal" =>$recordsTotal,  // necessary
    "recordsFiltered" =>$recordsFiltered, // necessary
    "data" =>$infos // necessary
),JSON_UNESCAPED_UNICODE);

clipboard.png

If

is just warning, you can set error_reporting (0); to close the interface error.
or switch all mysql_connect () to mysqli_connect () .


use mysqli


to reinstall an earlier version of php, on the server or, if possible, install several more versions, and switch directly if you want. Mysql_connect is a version below php5.5.


now mysql_connect is just about to be abandoned, not immediately. It can be used now, but try to replace it with mysqli


. Basically, mysql is replaced by mysqli .


see how mysql connections are handled in the framework. You can learn from


ctrl+f search mysql and replace it with mysqli

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2c1fc-33eb8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2c1fc-33eb8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?