D
D
Dmitry2017-09-20 00:44:27
PHP
Dmitry, 2017-09-20 00:44:27

Error in code, what's the problem?

I'm doing mysql + php lesson, but the following error occurs: Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\OpenServer\domains\test\mysql.php on line 10
Here is the code, I can't understand what error, I paste the code from the lesson, the same thing:

<?php

$link = mysqli_connect('localhost', "root", '', 'test');
if ( !$link ) die("Error");

$query = 'CREATE TABLE users(
    login       VARCHAR(20),
    password    VARCHAR(20)
)';
mysqli_query($query);

mysqli_close($link);
?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
DevMan, 2017-09-20
@good_br

the error says it all.
we open the dock by function and are surprised to find that we need 2 parameters, but in your code there is only one.

G
Gleb Nikolaev, 2017-09-20
@glebn

Try mysqli_query($link, $query);
Features of php7 and mysqli

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question