Warning: mysqli_query() expects at least 2 paramet

2019-01-20 20:43发布

I'm make a website and I keep on getting this error " Warning: mysqli_query() expects at least 2 parameters, 1 given in." It has been very frustrating and I can't seem to find a way to fix. Can anyone re-code my code or let me know how to fix it?

my code is:

<?php
$sitename = "xxxxx.com";
$link = mysqli_connect("xxxxx.com", "xxxxx.com", "xxxxx.com");
$db_selected = mysqli_select_db('xxxxx.com', $link);
mysqli_query("SET NAMES utf8");

function fetchinfo($rowname,$tablename,$finder,$findervalue) {
        if($finder == "2") $result = mysqli_query("SELECT $rowname FROM $tablename");
else $result = mysqli_query("SELECT $rowname FROM $tablename WHERE `$finder`='$findervalue'");
$row = mysqli_fetch_assoc($result);
return $row[$rowname];

} ?>

1条回答
狗以群分
2楼-- · 2019-01-20 21:12

You need to specify your connection.

$result = mysqli_query($link, "SELECT $rowname FROM $tablename WHERE $finder`='$findervalue'");

Plus, your connect is wrong if it's not entirely faked pseudocode (repeated *.com's). It should be similar to this:

$link=mysqli_connect("site","user","pw","db");

Fill in with your proper credentials.

查看更多
登录 后发表回答