I'm trying to create a very simple web app that checks if an element is inside the database.
If the element is located at least one time in the DB, then echo "YES", otherwise if the element doesn't exist just echo "NO".
Here's my code :
$mysql = mysqli_connect(/* can't share anything here */) or die ("ERROR CONNECTING TO THE DB");
if(isset($_POST['submit'])) {
$theAddress = $_POST['url'];
$result = "SELECT * FROM data WHERE url = " . $theAddress;
$query = mysqli_query($mysql, $result);
if (!$query) {
printf("Error");
} else {
printf("NO ERROR");
}
The problem here is that PHP always echo "Error". Why?