Your query has to be a string, it won’t conflict with PHP. Take a look at the example below. I suggest searching on the subject.
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM tb_dados WHERE cod_uf_mun = 1100205 AND no_curso LIKE '%vetérinaria%'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();
?>
mysqli_query($query);
Take a look at this site: https://www.w3schools.com/php/php_mysql_select.asp
it doesn’t work, like if I take what I have from AND it works more when I use AND or it doesn’t work and it doesn’t return any errors.
– Maicon Emanuel Neris Silva
Take a look at this other topic:https://stackoverflow.com/questions/34228090/cannot-query-mysql-database-viaphp
– Filipe L. Constante
Got Maicon?
– Filipe L. Constante
I managed to use your example and it worked
– Maicon Emanuel Neris Silva
Mark the answer as right :)
– Filipe L. Constante