Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

error message of mysql statement don't know why?

Links for php scripts

Moderators: macek, egami, gesf

error message of mysql statement don't know why?

Postby begeiste » Mon Aug 09, 2004 10:02 am

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: Select all
<?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>&nbsp;</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.]
begeiste
New php-forum User
New php-forum User
 
Posts: 83
Joined: Thu Jun 03, 2004 11:27 am

Return to PHP Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron