dongqing483174 2017-03-14 06:19
浏览 45
已采纳

警告:mysqli :: __ construct():MYSQLI PHP [重复]

I am not really familiar with mysqli that much, and I have to upgrade my script to mysqli, please could you help me sort it?

I have this

function getConnected($host,$db_user,$db_password,$db) {

       $mysqli = new mysqli($host, $db_user, $$db_password, $db);

       if($mysqli->connect_error) 
         die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());

       return $mysqli;
    }
    $mysqli = getConnected("localhost", "user_name_data456", "password123456", "user_database456");

and my query

        mysqli_query($mysqli,$sql);
        mysqli_query($mysqli,$sql2);
        mysqli_query($mysqli,$sql3);
        mysqli_query($mysqli,$sql4);
        mysqli_query($mysqli,$sql5);

The queries sql1 - 5 are working fine, it just has some insert things, I know doing more queries on mysql or mysqli isn't recommended, but I am just too tired.

Please help me sort it out. :/

</div>
  • 写回答

1条回答 默认 最新

  • doutu1939 2017-03-14 06:21
    关注

    Change this line

    $mysqli = new mysqli($host, $db_user, $$db_password, $db);
    

    to

    $mysqli = new mysqli($host, $db_user, $db_password, $db);
    

    removed extra $ from db_password variable

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 MATLAB代码补全插值
  • ¥15 Typegoose 中如何使用 arrayFilters 筛选并更新深度嵌套的子文档数组信息
  • ¥15 前后端分离的学习疑问?
  • ¥15 stata实证代码答疑
  • ¥50 husky+jaco2实现在gazebo与rviz中联合仿真
  • ¥15 dpabi预处理报错:Error using y_ExtractROISignal (line 251)
  • ¥15 在虚拟机中配置flume,无法将slave1节点的文件采集到master节点中
  • ¥15 husky+kinova jaco2 仿真
  • ¥15 zigbee终端设备入网失败
  • ¥15 金融监管系统怎么对7+4机构进行监管的