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
https://forums.phpfreaks.com/topic/6714-mysql-error/
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
https://forums.phpfreaks.com/topic/6714-mysql-error/#findComment-24393
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
https://forums.phpfreaks.com/topic/6714-mysql-error/#findComment-24396
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
https://forums.phpfreaks.com/topic/6714-mysql-error/#findComment-24520
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.