I have a PHP function that should return a database query:
function editprojectform(){
  global $conn;
  if(isset($_POST['project_id'])){
    $project_id = $_POST['project_id']; 
    $sql = "SELECT * FROM projects WHERE Project_ID=".$project_id;
      if ($conn->query($sql) === TRUE) {
        echo "It works";
      } else {
          echo "Error: " . $sql . "<br>" . $conn->error;
      }
  }
}
However it is printing out the error instead of printing out the project name:
Error: SELECT * FROM projects WHERE Project_ID=3
I can copy and paste this exact query into PHPadmin and it returns the expected result. I am trying to work out why it is not working here? I have a very similar function that deletes a record and it works fine.
Thank-you.
 
     
     
    