2015-05-22 2 views
-5
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_error() на линии 170?Предупреждение: mysqli_query() ожидает как минимум 2 параметра, 1 задано в

ошибки

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

Внимание: mysqli_query() ожидает, по меньшей мере, 2 параметра, 1 приведены в C: \ линии 170 Внимание: mysqli_error() ожидает ровно 1 параметр, 0 приведены в C: \ линии 170

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 

ответ

0

Вы должны указать идентификатор соединения db в качестве первого аргумента. Например:

+0

Идентификатор соединения отсутствует. ошибки решены, спасибо – retirement

0

ошибка вполне определенно: Вам нужно 2 параметра: - идентификатор соединения - запрос.

например:

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) 
)"); 

Без первого параметра, то MySQLi функция не знает, какую базу данных использовать, чтобы отобразилась вам ошибку выше

Смежные вопросы