mysqli_query() expects at least 2 Parameters, 1 Given in - PHP error

Asked

Viewed 13 times

0

I’m making a change in php, however, an error is appearing

Warning: mysqli_query() expects at least 2 parameters, 1 given in /home/canaljog/public_html/home/pages/principal.php on line 21

Connection to the bank

$pdo = new PDO("mysql:host=localhost;dbname=canaljog_website", "canaljog_sa", "tcmm@0105"); 

The error you are giving is in the main.php that is this

<?php 

                  $SQL_F = mysql_query("SELECT * FROM categoria WHERE nome_categoria='slider'");

                  while($ft = mysql_fetch_array($SQL_F)){
                      $id_ft = $ft['id_categoria'];
                  }

                  $SQL_FN = mysql_query("SELECT * FROM noticias WHERE categoria='$id_ft' ORDER BY id_noticia DESC LIMIT 1");
                  while($ftn = mysql_fetch_array($SQL_FN)){

                ?>


             <div class="item active">
              <a href="pages/noticia.php?id=<?php echo $ftn['id_noticia']; ?>">  


         <img src="adm/imagens/imgnoticia/<?php echo $ftn['imagem'];?>"  alt="<?php echo $ftn['titulo']; ?>" />

        </a>

<?php } ?>

What could be wrong ?

  • It is very strange this code, the connection is with PDO the error is with Mysqli and has old functions (mysql_*) error says that the first argument to be passed to mysqli_query() must be the connection.

  • 1

    Dude, your code is so wrong! You’re mixing 3 connection types, PDO, Mysql (which no longer exists in recent versions of php) and Mysqli. Focus on 1!

  • Ok. I’ll do via mysqli. I’ve already changed the connection. It connected well, but still gives such error. I already changed all mysql to mysqli

  • I’ve learned guys !! It was worth help !!!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.