notonurnelly Posted April 6, 2006 Share Posted April 6, 2006 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 readsWarning: 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 ThanksJamie Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 6, 2006 Share Posted April 6, 2006 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. Quote Link to comment Share on other sites More sharing options...
notonurnelly Posted April 6, 2006 Author Share Posted April 6, 2006 [!--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 readsWarning: 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 ThanksJamie[/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 Quote Link to comment Share on other sites More sharing options...
notonurnelly Posted April 6, 2006 Author Share Posted April 6, 2006 Can anyone help with this one it is still driving me madThanks in Adavance Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 6, 2006 Share Posted April 6, 2006 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] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.