Jump to content

Mysql Error


notonurnelly

Recommended Posts

Hi All,

I am getting the following error when trying to run the following code:

<?php do { ?>
<tr>
<td>
<?php echo $row_rstArtists['artist_name']; ?> </td>
<td><a href="artists.php?artist=<?php echo $row_rstArtists['arist_pk']; ?>">View</a></td>
</tr>
<?php } while ($row_rstArtists = mysql_fetch_assoc($rstArtists)); ?>
</table>

The error reads

Warning: mysql_fetch_assoc(): 4 is not a valid MySQL result.

The code was automatically generated using dreamweaver server behaviours.

Can anyone please help me to solve this problem.

Many Thanks
Jamie
Link to comment
Share on other sites

There is an error in your MySQL Query. Could you post your code here so we can see your query code.

Also I would recommend you to put the following:
[code]or die("MySQL Query Error: " . mysql_error());[/code] after mysql_query(... YOUR QUERY HERE ...)
That way MySQL will tell you whats wrong with SQL Query.
Link to comment
Share on other sites

[!--quoteo(post=362152:date=Apr 6 2006, 02:45 AM:name=notonurnelly)--][div class=\'quotetop\']QUOTE(notonurnelly @ Apr 6 2006, 02:45 AM) [snapback]362152[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Hi All,

I am getting the following error when trying to run the following code:

<?php do { ?>
<tr>
<td>
<?php echo $row_rstArtists['artist_name']; ?> </td>
<td><a href="artists.php?artist=<?php echo $row_rstArtists['arist_pk']; ?>">View</a></td>
</tr>
<?php } while ($row_rstArtists = mysql_fetch_assoc($rstArtists)); ?>
</table>

The error reads

Warning: mysql_fetch_assoc(): 4 is not a valid MySQL result.

The code was automatically generated using dreamweaver server behaviours.

Can anyone please help me to solve this problem.

Many Thanks
Jamie
[/quote]

Many Thanks for your reply,

here is the query code,

All of this code was developed by dreamweaver automatically. the example is taken from a book

mysql_select_db($database_Apress, $Apress);
$query_rstArtists = "SELECT * FROM artist";
$query_limit_rstArtists = sprintf("%s LIMIT %d, %d", $query_rstArtists, $startRow_rstArtists, $maxRows_rstArtists);
$rstArtists = mysql_query($query_limit_rstArtists, $Apress) or die(mysql_error());
$row_rstArtists = mysql_fetch_assoc($rstArtists);

Thanks
Link to comment
Share on other sites

Change this:[code] <?php do { ?>
<tr>
<td>
<?php echo $row_rstArtists['artist_name']; ?> </td>
<td><a href="artists.php?artist=<?php echo $row_rstArtists['arist_pk']; ?>">View</a></td>
</tr>
<?php } while ($row_rstArtists = mysql_fetch_assoc($rstArtists)); ?>
</table>[/code]to:[code] <?php while ($row_rstArtists = mysql_fetch_array($rstArtists)) { ?>
<tr>
<td>
<?php echo $row_rstArtists['artist_name']; ?> </td>
<td><a href="artists.php?artist=<?php echo $row_rstArtists['arist_pk']; ?>">View</a></td>
</tr>
<?php } ?>
</table>[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.