MySQLi Query Error in PHP

Sanju Menon

There problem my PHP Script. When I run the script it shows an error:

mysqli_query() expects at least 2 parameters, 1 given

The error is in this line:

$result=mysqli_query($selectQuery);

My script is below:

global $conn;
$prod_cat_names = "'" . str_replace( ",", "','", $values["prod_cat"] ) . "'";

/* Select Query as SELECT from previous example: */
$selectQuery = 
"
    SELECT sup_id, sup_name, sup_prod_name, sup_contactperson, sup_email, ".$values["tender_id"]." 
      FROM view_rfq_suppliersmerge 
     WHERE sup_prod_name IN ( {$prod_cat_names} )
     GROUP BY sup_name
";

/* Perform the query: */
$result=mysqli_query($selectQuery);
//$result = $db->query( $selectQuery );
//$result->setFetchMode( PDO::FETCH_ASSOC );


$insertQuery = array();

/* Process result and pre-fill Insert Query: */
 while($row=db_fetch_array($result))
{
    $insertQuery[] = "'" . implode( "', '",$row ) . "'";
}

/* Format INSERT Query: */
$insertQuery =
"
INSERT INTO rfq_suppliers 
            (sup_id, sup_name, sup_product, sup_contactperson, sup_contactperson_email, tender_id) 
            VALUES
            ('
            . implode( '), (', $insertQuery )
            ')
";

/* Perform INSERT Query: */
db_exec($insertQuery,$conn);
gavgrif

You have to link to the database connection to perform a query against the db.

 $result=mysqli_query($conn,$selectQuery);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related