Jump to content


Photo

Mysql Error


  • Please log in to reply
4 replies to this topic

#1 notonurnelly

notonurnelly
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 06 April 2006 - 07:45 AM

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

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 06 April 2006 - 08:33 AM

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:
or die("MySQL Query Error: " . mysql_error());
after mysql_query(... YOUR QUERY HERE ...)
That way MySQL will tell you whats wrong with SQL Query.


#3 notonurnelly

notonurnelly
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 06 April 2006 - 08:42 AM

[!--quoteo(post=362152:date=Apr 6 2006, 02:45 AM:name=notonurnelly)--][div class=\'quotetop\']QUOTE(notonurnelly @ Apr 6 2006, 02:45 AM) View Post[/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


#4 notonurnelly

notonurnelly
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 06 April 2006 - 03:06 PM

Can anyone help with this one it is still driving me mad

Thanks in Adavance

#5 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 06 April 2006 - 05:32 PM

Change this:
<?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>
to:
<?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>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users