mysql to mysqli change [duplicate]

孤街醉人 提交于 2020-04-07 08:05:03

问题


who can help me turn this code into mysqli? Ho tentato più soluzioni ma nn riesco a trasformarlo. THX

function GetFilesById($Id){
    $query = "SELECT * FROM allegati where id=$Id";
    $result = mysql_query($query);

    $data = MYSQL_RESULT($result,0,"data"); 
    $type = MYSQL_RESULT($result,0,"filetype"); 
    $name = MYSQL_RESULT($result,0,"filename"); 

    $myFile = array("data" => $data,
                    "type" => $type,
                    "name" => $name,
                    );
    return $myFile;
}

回答1:


Define DB connection variable like: $conn = new mysqli($servername, $username, $password);

Now instead of calling --- $result = mysql_query($query);

Just call --- $result = mysqli_query($conn, $query);



来源:https://stackoverflow.com/questions/61054748/mysql-to-mysqli-change

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!