Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 警告:mysqli_query()至少需要2个参数,其中1个在_Php_Mysqli - Fatal编程技术网

Php 警告:mysqli_query()至少需要2个参数,其中1个在

Php 警告:mysqli_query()至少需要2个参数,其中1个在,php,mysqli,Php,Mysqli,第170行也有mysqli_error() 错误 Receive 3 Warnings: mysqli_query() for function create_tb(), first parameters are "CREATE TABLE session id ()" and "CREATE TABLE user ()" on lines 151 and 170 haven't a clue what the second would be? 警告:mysqli_query(

第170行也有mysqli_error()

错误

Receive 3 Warnings: mysqli_query() for function create_tb(), first       parameters are "CREATE TABLE session id ()" and "CREATE TABLE user ()" on   lines 151 and 170 haven't a clue what the second would be?
警告:mysqli_query()至少需要2个参数,1个参数在C:\line 170中给出 警告:mysqli_error()只需要1个参数,0在C:\line 170中给出

Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\line   151

必须将db连接标识符作为第一个参数。例如:

enter code here

function create_tb()
{
// This function creates all the nessesary tables for database
global $db_link, $host_name, $db_user,$db_password,
$html_header, $html_footer, $db_name, $table_ads; 
$sql_query1=sql_create_tb();
$db_link = mysqli_connect($host_name, $db_user, $db_password);
mysqli_query($db_link, $sql_query1);                     

mysqli_query ("
CREATE TABLE session_id (
 id int(10) unsigned NOT NULL auto_increment,
 cookie varchar(255) NOT NULL default '',
 user_id int(10) NOT NULL default '0',
 last_request int(10) NOT NULL default '0',
 PRIMARY KEY  (id),
 UNIQUE KEY id (id)
 )");                                                      //line 151

mysqli_query ("
CREATE TABLE user (
 id int(10) unsigned NOT NULL auto_increment,
 user_name text NOT NULL,
 email text NOT NULL,
 passwd text NOT NULL,
 tel text NOT NULL,
 fax text NOT NULL,
 city text NOT NULL,
 state text NOT NULL,
 ip text NOT NULL,
 category text NOT NULL,
 lastup_date int(10) NOT NULL default '0',
 member_date int(10) NOT NULL default '0',
 PRIMARY KEY  (id),
 UNIQUE KEY id (id)
 )") or die (mysqli_error());                             //line 170

错误非常明显:您需要两个参数: -连接标识符 -查询

例如:


如果没有第一个参数,mysqli函数就不知道要使用哪个数据库,因此它会向您显示连接标识符丢失上面的错误。错误解决了,谢谢
mysqli_query($conn,"SELECT * FROM xxxxx");
mysqli_query ($db_link, "
CREATE TABLE session_id (
 id int(10) unsigned NOT NULL auto_increment,
 cookie varchar(255) NOT NULL default '',
 user_id int(10) NOT NULL default '0',
 last_request int(10) NOT NULL default '0',
 PRIMARY KEY  (id),
 UNIQUE KEY id (id)
 )");