PHP MySQL search form [duplicate]





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0
















This question already has an answer here:




  • Warning: mysqli_error() expects exactly 1 parameter, 0 given error [closed]

    3 answers



  • How to display errors for my MySQLi query? [duplicate]

    3 answers



  • When to use single quotes, double quotes, and back ticks in MySQL

    12 answers



  • Reference - What does this error mean in PHP?

    32 answers




I'm trying to create a search form in php that is connected to a mysql db, but i have some problems and i don't know how to solve them.



I have a db with some different tables (db-brand1, db-brand2, db-brand3 and db-brand4) in which are some rows with different brand clients and obv clients so. All tables contain row as: firstame, lastname, id_client, id_2client, email ( p.k. )



so I created two php files. One for connection db called conn.php that I report below



<?php
$host = "localhost";
$userName = ".....";
$password = ".....";
$dbName = ".....";

// Create database connection
$conn = new mysqli($host, $userName, $password, $dbName);

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>


and connection to db works correctly.



and other file that include the search form and query result called as search.php



<?
error_reporting(E_ALL);
ini_set('display_errors', '1');
include("conn.php");

$search_output = "";
if (isset($_POST["submit"])){
if($_POST['brand'] == "brand1"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand1 WHERE email = 'email";
}

else if ($_POST['brand'] == "brand2"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand2 WHERE email = 'email'";
}

else if ($_POST['brand'] == "brand3"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand3 WHERE email = 'email'";
}

else if ($_POST['brand'] == "brand4"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand4 WHERE email = 'email'";
}



$query = mysqli_query($conn,$sqlcommand) or die (mysqli_error($conn));
$search_output .="<hr />query result";
if ($row = mysqli_fetch_array($query)){
$email = $row ["email"];
$id-client = $row ["id_client"];
$id-2client = $row ["id_2client"];
$search_output .= "<p> $email - $id_client - $id_2client </p>";

} else{
$search_output= "<hr /> No result";
}
}
?>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<title>Search form</title>
</head>
<body>
<section>
<div class="container">
<div class="row my-5">
<h1>Search form</h1>
</div>
<form name="search-info" method="post" action="<?php echo $_SERVER ['PHP_SELF']; ?>">
<div class="form-group">
<label for="exampleFormControlInput1">Enter client email</label>
<input type="email" class="form-control" id="exampleFormControlInput1" placeholder="clientemail@email.com" name="email">
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Select the brand</label>
<select class="form-control" id="exampleFormControlSelect1" name="brand">
<option value="brand1">Brand1</option>
<option value="brand2">Brand2</option>
<option value="brand3">Brand3</option>
<option value="brand4">Brand4</option>
</select>
</div>
<button class="btn btn-primary" type="submit" name="submit">Submit</button>
</form>

</div>
</section>

<section>
<div class="container">
<div class="row">
<p><?php echo $search_output; ?></p>
</div>
</div>
</section>


<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQx"</script>
</body>
</html>


But nothing works correctly... i haven't php error, but i think that are problem with this part of code



$query = mysqli_query($conn,$sqlcommand)


or with correct execution of it



$search_output = "";
if (isset($_POST["submit"])){
if($_POST['brand'] == "brand1"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand1 WHERE email = 'email";
}

else if ($_POST['brand'] == "brand2"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand2 WHERE email = 'email'";
}

else if ($_POST['brand'] == "brand3"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand3 WHERE email = 'email'";
}

else if ($_POST['brand'] == "brand4"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand4 WHERE email = 'email'";
}


If i try to input an email contained in db_brand2 and select so brand2 from select option, i receive error as below



Warning: mysqli_error() expects exactly 1 parameter, 0 given in /home/../../search.php on line 26


that is $query = mysqli_query($conn,$sqlcommand) or die (mysqli_error());



How could solve it :/ ?



Thank you so much










share|improve this question















marked as duplicate by Funk Forty Niner mysql
Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 3 at 14:06


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • mysqli_error() that requires a connection and your query failed because of a few reasons. Hint: "hyphens" = "minus".

    – Funk Forty Niner
    Jan 3 at 14:05













  • Also, never use - in database names. only _ if you really need a separator

    – Joppe De Cuyper
    Jan 3 at 14:06











  • Hi, thank you. I wrote in a wrong way here. I used minus _ in database names in real php file, so problem isn't here.

    – Paolo Gregorio
    Jan 3 at 14:11











  • i don't understand why this my answer was put as duplicate. I read other post similar mine without find correct solution. However i added mysqli_error($conn) instead previous mysqli_error( ), but whentry to search something from search form ( connected to my db ) the only answer i have is "No result", but i should have in answer correct result of query. Someone can help me to check if there're some problems with this block of if - else ?

    – Paolo Gregorio
    Jan 3 at 17:17


















0
















This question already has an answer here:




  • Warning: mysqli_error() expects exactly 1 parameter, 0 given error [closed]

    3 answers



  • How to display errors for my MySQLi query? [duplicate]

    3 answers



  • When to use single quotes, double quotes, and back ticks in MySQL

    12 answers



  • Reference - What does this error mean in PHP?

    32 answers




I'm trying to create a search form in php that is connected to a mysql db, but i have some problems and i don't know how to solve them.



I have a db with some different tables (db-brand1, db-brand2, db-brand3 and db-brand4) in which are some rows with different brand clients and obv clients so. All tables contain row as: firstame, lastname, id_client, id_2client, email ( p.k. )



so I created two php files. One for connection db called conn.php that I report below



<?php
$host = "localhost";
$userName = ".....";
$password = ".....";
$dbName = ".....";

// Create database connection
$conn = new mysqli($host, $userName, $password, $dbName);

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>


and connection to db works correctly.



and other file that include the search form and query result called as search.php



<?
error_reporting(E_ALL);
ini_set('display_errors', '1');
include("conn.php");

$search_output = "";
if (isset($_POST["submit"])){
if($_POST['brand'] == "brand1"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand1 WHERE email = 'email";
}

else if ($_POST['brand'] == "brand2"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand2 WHERE email = 'email'";
}

else if ($_POST['brand'] == "brand3"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand3 WHERE email = 'email'";
}

else if ($_POST['brand'] == "brand4"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand4 WHERE email = 'email'";
}



$query = mysqli_query($conn,$sqlcommand) or die (mysqli_error($conn));
$search_output .="<hr />query result";
if ($row = mysqli_fetch_array($query)){
$email = $row ["email"];
$id-client = $row ["id_client"];
$id-2client = $row ["id_2client"];
$search_output .= "<p> $email - $id_client - $id_2client </p>";

} else{
$search_output= "<hr /> No result";
}
}
?>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<title>Search form</title>
</head>
<body>
<section>
<div class="container">
<div class="row my-5">
<h1>Search form</h1>
</div>
<form name="search-info" method="post" action="<?php echo $_SERVER ['PHP_SELF']; ?>">
<div class="form-group">
<label for="exampleFormControlInput1">Enter client email</label>
<input type="email" class="form-control" id="exampleFormControlInput1" placeholder="clientemail@email.com" name="email">
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Select the brand</label>
<select class="form-control" id="exampleFormControlSelect1" name="brand">
<option value="brand1">Brand1</option>
<option value="brand2">Brand2</option>
<option value="brand3">Brand3</option>
<option value="brand4">Brand4</option>
</select>
</div>
<button class="btn btn-primary" type="submit" name="submit">Submit</button>
</form>

</div>
</section>

<section>
<div class="container">
<div class="row">
<p><?php echo $search_output; ?></p>
</div>
</div>
</section>


<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQx"</script>
</body>
</html>


But nothing works correctly... i haven't php error, but i think that are problem with this part of code



$query = mysqli_query($conn,$sqlcommand)


or with correct execution of it



$search_output = "";
if (isset($_POST["submit"])){
if($_POST['brand'] == "brand1"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand1 WHERE email = 'email";
}

else if ($_POST['brand'] == "brand2"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand2 WHERE email = 'email'";
}

else if ($_POST['brand'] == "brand3"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand3 WHERE email = 'email'";
}

else if ($_POST['brand'] == "brand4"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand4 WHERE email = 'email'";
}


If i try to input an email contained in db_brand2 and select so brand2 from select option, i receive error as below



Warning: mysqli_error() expects exactly 1 parameter, 0 given in /home/../../search.php on line 26


that is $query = mysqli_query($conn,$sqlcommand) or die (mysqli_error());



How could solve it :/ ?



Thank you so much










share|improve this question















marked as duplicate by Funk Forty Niner mysql
Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 3 at 14:06


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • mysqli_error() that requires a connection and your query failed because of a few reasons. Hint: "hyphens" = "minus".

    – Funk Forty Niner
    Jan 3 at 14:05













  • Also, never use - in database names. only _ if you really need a separator

    – Joppe De Cuyper
    Jan 3 at 14:06











  • Hi, thank you. I wrote in a wrong way here. I used minus _ in database names in real php file, so problem isn't here.

    – Paolo Gregorio
    Jan 3 at 14:11











  • i don't understand why this my answer was put as duplicate. I read other post similar mine without find correct solution. However i added mysqli_error($conn) instead previous mysqli_error( ), but whentry to search something from search form ( connected to my db ) the only answer i have is "No result", but i should have in answer correct result of query. Someone can help me to check if there're some problems with this block of if - else ?

    – Paolo Gregorio
    Jan 3 at 17:17














0












0








0









This question already has an answer here:




  • Warning: mysqli_error() expects exactly 1 parameter, 0 given error [closed]

    3 answers



  • How to display errors for my MySQLi query? [duplicate]

    3 answers



  • When to use single quotes, double quotes, and back ticks in MySQL

    12 answers



  • Reference - What does this error mean in PHP?

    32 answers




I'm trying to create a search form in php that is connected to a mysql db, but i have some problems and i don't know how to solve them.



I have a db with some different tables (db-brand1, db-brand2, db-brand3 and db-brand4) in which are some rows with different brand clients and obv clients so. All tables contain row as: firstame, lastname, id_client, id_2client, email ( p.k. )



so I created two php files. One for connection db called conn.php that I report below



<?php
$host = "localhost";
$userName = ".....";
$password = ".....";
$dbName = ".....";

// Create database connection
$conn = new mysqli($host, $userName, $password, $dbName);

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>


and connection to db works correctly.



and other file that include the search form and query result called as search.php



<?
error_reporting(E_ALL);
ini_set('display_errors', '1');
include("conn.php");

$search_output = "";
if (isset($_POST["submit"])){
if($_POST['brand'] == "brand1"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand1 WHERE email = 'email";
}

else if ($_POST['brand'] == "brand2"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand2 WHERE email = 'email'";
}

else if ($_POST['brand'] == "brand3"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand3 WHERE email = 'email'";
}

else if ($_POST['brand'] == "brand4"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand4 WHERE email = 'email'";
}



$query = mysqli_query($conn,$sqlcommand) or die (mysqli_error($conn));
$search_output .="<hr />query result";
if ($row = mysqli_fetch_array($query)){
$email = $row ["email"];
$id-client = $row ["id_client"];
$id-2client = $row ["id_2client"];
$search_output .= "<p> $email - $id_client - $id_2client </p>";

} else{
$search_output= "<hr /> No result";
}
}
?>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<title>Search form</title>
</head>
<body>
<section>
<div class="container">
<div class="row my-5">
<h1>Search form</h1>
</div>
<form name="search-info" method="post" action="<?php echo $_SERVER ['PHP_SELF']; ?>">
<div class="form-group">
<label for="exampleFormControlInput1">Enter client email</label>
<input type="email" class="form-control" id="exampleFormControlInput1" placeholder="clientemail@email.com" name="email">
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Select the brand</label>
<select class="form-control" id="exampleFormControlSelect1" name="brand">
<option value="brand1">Brand1</option>
<option value="brand2">Brand2</option>
<option value="brand3">Brand3</option>
<option value="brand4">Brand4</option>
</select>
</div>
<button class="btn btn-primary" type="submit" name="submit">Submit</button>
</form>

</div>
</section>

<section>
<div class="container">
<div class="row">
<p><?php echo $search_output; ?></p>
</div>
</div>
</section>


<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQx"</script>
</body>
</html>


But nothing works correctly... i haven't php error, but i think that are problem with this part of code



$query = mysqli_query($conn,$sqlcommand)


or with correct execution of it



$search_output = "";
if (isset($_POST["submit"])){
if($_POST['brand'] == "brand1"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand1 WHERE email = 'email";
}

else if ($_POST['brand'] == "brand2"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand2 WHERE email = 'email'";
}

else if ($_POST['brand'] == "brand3"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand3 WHERE email = 'email'";
}

else if ($_POST['brand'] == "brand4"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand4 WHERE email = 'email'";
}


If i try to input an email contained in db_brand2 and select so brand2 from select option, i receive error as below



Warning: mysqli_error() expects exactly 1 parameter, 0 given in /home/../../search.php on line 26


that is $query = mysqli_query($conn,$sqlcommand) or die (mysqli_error());



How could solve it :/ ?



Thank you so much










share|improve this question

















This question already has an answer here:




  • Warning: mysqli_error() expects exactly 1 parameter, 0 given error [closed]

    3 answers



  • How to display errors for my MySQLi query? [duplicate]

    3 answers



  • When to use single quotes, double quotes, and back ticks in MySQL

    12 answers



  • Reference - What does this error mean in PHP?

    32 answers




I'm trying to create a search form in php that is connected to a mysql db, but i have some problems and i don't know how to solve them.



I have a db with some different tables (db-brand1, db-brand2, db-brand3 and db-brand4) in which are some rows with different brand clients and obv clients so. All tables contain row as: firstame, lastname, id_client, id_2client, email ( p.k. )



so I created two php files. One for connection db called conn.php that I report below



<?php
$host = "localhost";
$userName = ".....";
$password = ".....";
$dbName = ".....";

// Create database connection
$conn = new mysqli($host, $userName, $password, $dbName);

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>


and connection to db works correctly.



and other file that include the search form and query result called as search.php



<?
error_reporting(E_ALL);
ini_set('display_errors', '1');
include("conn.php");

$search_output = "";
if (isset($_POST["submit"])){
if($_POST['brand'] == "brand1"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand1 WHERE email = 'email";
}

else if ($_POST['brand'] == "brand2"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand2 WHERE email = 'email'";
}

else if ($_POST['brand'] == "brand3"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand3 WHERE email = 'email'";
}

else if ($_POST['brand'] == "brand4"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand4 WHERE email = 'email'";
}



$query = mysqli_query($conn,$sqlcommand) or die (mysqli_error($conn));
$search_output .="<hr />query result";
if ($row = mysqli_fetch_array($query)){
$email = $row ["email"];
$id-client = $row ["id_client"];
$id-2client = $row ["id_2client"];
$search_output .= "<p> $email - $id_client - $id_2client </p>";

} else{
$search_output= "<hr /> No result";
}
}
?>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<title>Search form</title>
</head>
<body>
<section>
<div class="container">
<div class="row my-5">
<h1>Search form</h1>
</div>
<form name="search-info" method="post" action="<?php echo $_SERVER ['PHP_SELF']; ?>">
<div class="form-group">
<label for="exampleFormControlInput1">Enter client email</label>
<input type="email" class="form-control" id="exampleFormControlInput1" placeholder="clientemail@email.com" name="email">
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Select the brand</label>
<select class="form-control" id="exampleFormControlSelect1" name="brand">
<option value="brand1">Brand1</option>
<option value="brand2">Brand2</option>
<option value="brand3">Brand3</option>
<option value="brand4">Brand4</option>
</select>
</div>
<button class="btn btn-primary" type="submit" name="submit">Submit</button>
</form>

</div>
</section>

<section>
<div class="container">
<div class="row">
<p><?php echo $search_output; ?></p>
</div>
</div>
</section>


<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQx"</script>
</body>
</html>


But nothing works correctly... i haven't php error, but i think that are problem with this part of code



$query = mysqli_query($conn,$sqlcommand)


or with correct execution of it



$search_output = "";
if (isset($_POST["submit"])){
if($_POST['brand'] == "brand1"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand1 WHERE email = 'email";
}

else if ($_POST['brand'] == "brand2"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand2 WHERE email = 'email'";
}

else if ($_POST['brand'] == "brand3"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand3 WHERE email = 'email'";
}

else if ($_POST['brand'] == "brand4"){
$sqlcommand="SELECT email, id_client, id_2client FROM db-brand4 WHERE email = 'email'";
}


If i try to input an email contained in db_brand2 and select so brand2 from select option, i receive error as below



Warning: mysqli_error() expects exactly 1 parameter, 0 given in /home/../../search.php on line 26


that is $query = mysqli_query($conn,$sqlcommand) or die (mysqli_error());



How could solve it :/ ?



Thank you so much





This question already has an answer here:




  • Warning: mysqli_error() expects exactly 1 parameter, 0 given error [closed]

    3 answers



  • How to display errors for my MySQLi query? [duplicate]

    3 answers



  • When to use single quotes, double quotes, and back ticks in MySQL

    12 answers



  • Reference - What does this error mean in PHP?

    32 answers








php mysql forms search






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 3 at 17:09







Paolo Gregorio

















asked Jan 3 at 14:04









Paolo GregorioPaolo Gregorio

12




12




marked as duplicate by Funk Forty Niner mysql
Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 3 at 14:06


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Funk Forty Niner mysql
Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 3 at 14:06


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • mysqli_error() that requires a connection and your query failed because of a few reasons. Hint: "hyphens" = "minus".

    – Funk Forty Niner
    Jan 3 at 14:05













  • Also, never use - in database names. only _ if you really need a separator

    – Joppe De Cuyper
    Jan 3 at 14:06











  • Hi, thank you. I wrote in a wrong way here. I used minus _ in database names in real php file, so problem isn't here.

    – Paolo Gregorio
    Jan 3 at 14:11











  • i don't understand why this my answer was put as duplicate. I read other post similar mine without find correct solution. However i added mysqli_error($conn) instead previous mysqli_error( ), but whentry to search something from search form ( connected to my db ) the only answer i have is "No result", but i should have in answer correct result of query. Someone can help me to check if there're some problems with this block of if - else ?

    – Paolo Gregorio
    Jan 3 at 17:17



















  • mysqli_error() that requires a connection and your query failed because of a few reasons. Hint: "hyphens" = "minus".

    – Funk Forty Niner
    Jan 3 at 14:05













  • Also, never use - in database names. only _ if you really need a separator

    – Joppe De Cuyper
    Jan 3 at 14:06











  • Hi, thank you. I wrote in a wrong way here. I used minus _ in database names in real php file, so problem isn't here.

    – Paolo Gregorio
    Jan 3 at 14:11











  • i don't understand why this my answer was put as duplicate. I read other post similar mine without find correct solution. However i added mysqli_error($conn) instead previous mysqli_error( ), but whentry to search something from search form ( connected to my db ) the only answer i have is "No result", but i should have in answer correct result of query. Someone can help me to check if there're some problems with this block of if - else ?

    – Paolo Gregorio
    Jan 3 at 17:17

















mysqli_error() that requires a connection and your query failed because of a few reasons. Hint: "hyphens" = "minus".

– Funk Forty Niner
Jan 3 at 14:05







mysqli_error() that requires a connection and your query failed because of a few reasons. Hint: "hyphens" = "minus".

– Funk Forty Niner
Jan 3 at 14:05















Also, never use - in database names. only _ if you really need a separator

– Joppe De Cuyper
Jan 3 at 14:06





Also, never use - in database names. only _ if you really need a separator

– Joppe De Cuyper
Jan 3 at 14:06













Hi, thank you. I wrote in a wrong way here. I used minus _ in database names in real php file, so problem isn't here.

– Paolo Gregorio
Jan 3 at 14:11





Hi, thank you. I wrote in a wrong way here. I used minus _ in database names in real php file, so problem isn't here.

– Paolo Gregorio
Jan 3 at 14:11













i don't understand why this my answer was put as duplicate. I read other post similar mine without find correct solution. However i added mysqli_error($conn) instead previous mysqli_error( ), but whentry to search something from search form ( connected to my db ) the only answer i have is "No result", but i should have in answer correct result of query. Someone can help me to check if there're some problems with this block of if - else ?

– Paolo Gregorio
Jan 3 at 17:17





i don't understand why this my answer was put as duplicate. I read other post similar mine without find correct solution. However i added mysqli_error($conn) instead previous mysqli_error( ), but whentry to search something from search form ( connected to my db ) the only answer i have is "No result", but i should have in answer correct result of query. Someone can help me to check if there're some problems with this block of if - else ?

– Paolo Gregorio
Jan 3 at 17:17












0






active

oldest

votes

















0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

ts Property 'filter' does not exist on type '{}'

mat-slide-toggle shouldn't change it's state when I click cancel in confirmation window