Warning mysqli query expects at least 2 parameters 1 given What

0 votes

I have to build a PHP page that selects two names from a database and displays them. But when I run my code it gives an error.

Warning: mysqli_query() expects at least 2 parameters, 1 given in /home/tdoylex1/public_html/dorkhub/index.php on line 4

Warning: mysqli_query() expects at least 2 parameters, 1 given in /home/tdoylex1/public_html/dorkhub/index.php on line 8

My code:

<?php mysqli_connect(localhost,tdoylex1_dork,dorkk,tdoylex1_dork);
$name1 = mysqli_query("SELECT name1 FROM users
ORDER BY RAND()
LIMIT 1");

$name2 = mysqli_query("SELECT name FROM users
ORDER BY RAND()
LIMIT 1");

?>

<title>DorkHub. The online name-rating website.</title>
<link rel="stylesheet" type="text/css" href="style.css">
<body bgcolor='EAEAEA'>
<center>
<div id='TITLE'>
    <h2>DorkHub. The online name-rating website.</h2>
</div>
    <p>
    <br>
    <h3><?php echo $name1; ?></h3><h4> against </h4><h3><?php echo $name1; ?></h3>
    <br><br>
    <h2 style='font-family:Arial, Helvetica, sans-serif;'>Who's sounds the dorkiest?</h2>
    <br><br>
    <div id='vote'>
    <h3 id='done' style='margin-right: 10px'>VOTE FOR FIRST</h3><h3 id='done'>VOTE FOR LAST</h3>

Can someone explain to me why this warning appears and how to overcome this?

May 12, 2022 in PHP by Kichu
• 19,050 points
1,020 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
1 answer

Error:mysql_fetch_array() expects parameter 1 to be resource, boolean given

Hello @kartik, Error occurred here was due to ...READ MORE

answered Sep 16, 2020 in PHP by Niroj
• 82,880 points
3,483 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Error:invalid address: @invalid@email You must provide at least one recipient email address.

Hello, PHPMailer uses Exceptions. Try the following code: require_once '../class.phpmailer.php'; $mail = new ...READ MORE

answered Nov 13, 2020 in PHP by Niroj
• 82,880 points
3,741 views
0 votes
2 answers

Define a SQL query? What is the difference between SELECT and UPDATE Query? How do you use SQL in SAS?

HI.. SQL is Structured Query Language, which is ...READ MORE

answered Aug 8, 2020 in PHP by anonymous
9,626 views
0 votes
1 answer

What are the vulnerability related to PHP Form?

Hii, The $_SERVER["PHP_SELF"] variable can be used by ...READ MORE

answered Feb 13, 2020 in PHP by Niroj
• 82,880 points
2,733 views
0 votes
1 answer
0 votes
1 answer

mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in.

The issue is that the query given to mysqli_query() is ...READ MORE

answered May 1, 2022 in Other DevOps Questions by narikkadan
• 63,420 points
1,296 views
0 votes
0 answers

Object of class mysqli_result could not be converted to string

Code: $result = mysqli_query($con, "SELECT classtype FROM learn_users ...READ MORE

May 15, 2022 in PHP by Kichu
• 19,050 points
1,292 views
0 votes
0 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP