dongzhimin2231 2018-05-07 10:45
浏览 675

警告:mysqli_select_db()期望参数1为mysqli,第13行给出的字符串[duplicate]

This question already has an answer here:

<?php //start php tag 
//include connect.php page for database connection
include('connect.php'); 

if(isset($_REQUEST['submit'])!='')
    if ($_REQUEST['name']==''||$_REQUEST['email']=''||$_REQUEST['password']==''||$_REQUEST['repassword']==''){
        Echo "please fill theempty field.";
    }Else{
        $mysqli="insert into user(naam,email,password)values('".$_REQUEST['name']."','".$_REQUEST['email'].",'".$_REQUEST['password']."')";
        $res=mysqli_query($mysqli);
        if($res) { 
            Echo "Recordsuccessfully inserted"; 
        } Else{
            Echo "There is some problem in inserting record"; 
        } 
    } 
}
?>

I keep getting the same error and can't find what's actually the problem, or maybe I just didn't see.

this is my connection

<?php
$hostname="localhost"; 
$username="root"; 
$password="";
$database="website";
$mysqli=mysqli_connect($hostname,$username,$password,$database);
if(! $mysqli){
    die("Connection Failed:".mysqli_error());
}
mysqli_select_db($database,$mysqli);
?>
</div>
  • 写回答

1条回答 默认 最新

  • dr2898 2018-05-07 10:56
    关注

    You only pass 1 argument into the function. This is wrong. You need two arguments. You have only passed the second.

    The first argument is the connection.

    http://php.net/manual/en/function.mysqli-connect.php

    Please refer to the manual:

    bool mysqli_select_db ( mysqli $link , string $dbname )
    

    http://php.net/manual/en/mysqli.select-db.php

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?