mysql_fetch_array()期望参数1是资源,在[关闭]中给出布尔值

this is the code that I have been using to try and connect to a database and retrieve data from it but it's not showing images properly. All other content is displayed properly.

//This php quote is test2.php
<?php

$dbhost='localhost';
$dbuser='root';
$dbpass='';
$db='dynamic';

$con = mysql_connect("localhost","elemental","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }



mysql_selectdb($db);

?>


<?php
include 'test2.php';

$query="selelct * from data";
$result=mysql_query($query);

while ($data=mysql_fetch_array($result)) {

echo '<h3>' . $data['id'] . '</h3>';
    echo '<h3>' . $data['name'] . '</h3>';

}


?>

You have 2 typos:

$query="selelct * from data";  

should be:

$query="select * from data";  //select not selelct

and

mysql_selectdb($db);  

should be:

mysql_select_db($db);

A few oversights or issues in your code. Including repeating yourself for no known reason, and failing to test your variables/actions as you progress.

<?php

$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$dbbase = 'dynamic';

// WAS
// $con = mysql_connect("localhost","elemental","");
// why have your variables above if you hardcode them?
if( !( $con = mysql_connect( $dbhost , $dbuser , $dbpass ) ) ){
  error_log( 'MySQL Server Connection Failed - '.mysql_error() );
  // Never echo your errors publicly
  die( 'Cannot connect to database, but I am not going to show you why publicly.' );
}
if( !mysql_select_db( $dbbase ) ){
  error_log( 'MySQL Database Connection Failed - '.mysql_error() );
  // Never echo your errors publicly
  die( 'Cannot connect to database, but I am not going to show you why publicly.' );
}

include( 'test2.php' );

// WAS
// $query="selelct * from data";
// check your spelling!
$query = 'SELECT * FROM data';

if( !( $result = mysql_query( $query ) ) ){
  error_log( 'MySQL Query Failed - '.mysql_error() );
  die( 'Cannot query the database, but I am not going to show you why publicly.' );
}
if( !mysql_num_rows( $result ) ){
  echo 'No Records Found';
}else{
  while( $d = mysql_fetch_array( $result ) ){
    echo '<h3>'.$d['id'].'</h3><h3>'.$d['name'].'</h3>';
  }
}