Why write code to hide errors from yourself?
if (mysqli_connect_error()) {
echo "Failed to connect to the database!";
}
...
$stream = mysqli_query($conn,$sql);
echo "<br>";
echo "stream = " $stream;
$stream1 = mysqli_fetch_field($stream);
echo "<br>";
echo "streamID = " $stream1;
In development, in testing, and in production, all code that can elicit errors needs error trapping, minimally something like ...
$debug = TRUE;
$err = "";
ini_set( "log_errors", 1 );
ini_set( "error_log", "path_to_your_error_file" );
ini_set( "display_errors", $debug );
$conn = mysqli_connect(...);
if( mysqli_connect_error() ) {
$err = mysqli_connect_error();
if( $debug ) exit( "Error: $err" );
logerr( $err );
exit( "Failed to connect to the database." );
}
...
$stream = mysqli_query($conn,$sql);
if( !$stream ( {
$err = mysqli_error( $conn );
logerr( $err );
if( $debug ) echo "Error: $err<br>" );
...
}
...
$stream1 = mysqli_fetch_field($stream);
if( !$stream ( {
... etc ...
}