What potential reasons could cause the first ibase_query function to not work in conjunction with the others in PHP?

The potential reasons that could cause the first ibase_query function to not work in conjunction with the others in PHP could be incorrect database connection parameters, SQL syntax errors, or insufficient permissions to access the database. To solve this issue, ensure that the connection parameters are correct, double-check the SQL query for any syntax errors, and verify that the user has the necessary permissions to execute the query.

<?php
// Correcting the database connection parameters and fixing any SQL syntax errors
$host = 'localhost';
$username = 'username';
$password = 'password';
$database = 'database_name';

$conn = ibase_connect($host, $username, $password, 'UTF8');

if (!$conn) {
    echo "Failed to connect to database: " . ibase_errmsg();
    exit;
}

$sql = "SELECT * FROM table_name";
$query = ibase_query($conn, $sql);

if (!$query) {
    echo "Failed to execute query: " . ibase_errmsg();
    exit;
}

// Fetching and displaying results
while ($row = ibase_fetch_assoc($query)) {
    print_r($row);
}

ibase_close($conn);
?>