I am trying to perform this query in PHP however it keeps returning false. I have tried the query in phpMyAdmin and it works fine so if anyone can spot what is wrong that would
Close first connection using mysqli_close($conn);
after first query is finished then open a new connection with include 'connection.php';
before the second query. Credit to @Chay22
If you are using parameterized queries, then you have to pass the value for the parameter when you execute the prepared query.
You also have to execute
the prepared query. The prepare just passes the query to the database for compilation and optimisation, it does not actually execute the query.
Also if you get an error in these database access statement, there are functions/methods you should use to show the the actuall error message which are a lot more useful than outputting something you make up yourself like echo "Error creating SQL statement";
Also the ;
is not necessary.
$stmt = $conn->prepare("SELECT * FROM artist WHERE artID != ?");
if ( $stmt === false ){
echo $conn->error;
exit;
}
$stmt->bindParam('i', $some_variable)
$result = $stmt->execute();
if ( $result === false ) {
echo $stmt->error;
exit;
}