error message of mysql statement don't know why?

A

Anonymous

Guest
Here is the url: http://www.symphonyimage.com/index.php
once you click on the view button of the third record "Chen's Enterprises",
I got this error message:
Warning: mysql_fetch_assoc(): 4 is not a valid MySQL result resource in /home/symphon1/public_html/artist.php on line 47, but don't know why didn't get the error message on the first and second records.

And this is the original php codes:

Code:
<?php require_once('Connections/apress.php'); ?>
<?php
$colname_rstArtists = "1";
if (isset($HTTP_GET_VARS['artist'])) {
  $colname_rstArtists = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['artist'] : addslashes($HTTP_GET_VARS['artist']);
}
mysql_select_db($database_apress, $apress);
$query_rstArtists = sprintf("SELECT * FROM artist WHERE artist_ID = %s", $colname_rstArtists);
$rstArtists = mysql_query($query_rstArtists, $apress) or die(mysql_error());
$row_rstArtists = mysql_fetch_assoc($rstArtists);
$totalRows_rstArtists = mysql_num_rows($rstArtists);

$colname_rstCDs = "1";
if (isset($HTTP_GET_VARS['artist'])) {
  $colname_rstCDs = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['artist'] : addslashes($HTTP_GET_VARS['artist']);
}
mysql_select_db($database_apress, $apress);
$query_rstCDs = sprintf("SELECT * FROM cd WHERE cd_artist = %s", $colname_rstCDs);
$rstCDs = mysql_query($query_rstCDs, $apress) or die(mysql_error());
$row_rstCDs = mysql_fetch_assoc($rstCDs);
$totalRows_rstCDs = mysql_num_rows($rstCDs);
?>
<?php
mysql_free_result($rstArtists);

mysql_free_result($rstCDs);
?>

<table width="200" border="0" cellspacing="2" cellpadding="2">
  <tr>
    <td><?php echo $row_rstArtists['artist_name']; ?></td>
  </tr>
</table>
<p>CD informaton:
</p>
<?php if ($totalRows_rstCDs > 0) { // Show if recordset not empty ?>
<table width="650" border="0" cellspacing="2" cellpadding="2">
  <tr> 
    <td>CD titles</td>
    <td> </td>
  </tr>
  <?php do { ?>
  <tr> 
    <td><?php echo $row_rstCDs['cd_name']; ?></td>
    <td><a href="/cd.php?cd=<?php echo $row_rstCDs['cd_ID']; ?>">edit</a></td>
  </tr>
  <?php } while ($row_rstCDs = mysql_fetch_assoc($rstCDs)); ?>
</table>
<?php } // Show if recordset not empty ?>
<?php if ($totalRows_rstCDs == 0) { // Show if recordset empty ?>
<p>No CDs in database for this artist</p>
<?php } // Show if recordset empty ?>

Any inputs are appreciated!

[Edit by swirlee: Please use
Code:
 tags when posting code.][/i]
 
Back
Top