Hi,

I have a query which I am trying to repeat. However when I place them next together the second one creates an error. However when I seperate them with another query they both work independently. Can anyone please advise why they wont work next to each other?

This works:


Code:
	  <div class="followbuttonimagearea">
												<?php
$query = mysql_query("SELECT * FROM follow JOIN users WHERE user_id = " . ($row['id']) . " ORDER BY follow_user_id ASC LIMIT 10");
while($row = mysql_fetch_array($query)) {
                 
	  ?>	
	  
<div class="followimage">
<a href="/test/profileinserttest.php?ID=<?php echo $row['follow_user_id']; ?>"><img src="/test/images/<?php echo $row['logo']; ?>" alt="<?php echo $row['company']; ?>" /></a>
			 	</div>

<?php
}

	  ?>
</div>

<?php
if (isset($_GET['ID']))
$ID = mysql_real_escape_string($_GET['ID']);
$sql = "SELECT * FROM users WHERE ID = '$ID'";
$res = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($res); // no need to loop since you are retrieving only one row
$num_rows = mysql_num_rows($res); // check to see if any results were found, just in case someone puts an ID in the url without clicking on your link
?>

	  <div class="followbuttonimagearea">
												<?php
$query = mysql_query("SELECT * FROM follow JOIN users WHERE user_id = " . ($row['id']) . " ORDER BY follow_user_id ASC LIMIT 10");
while($row = mysql_fetch_array($query)) {     
	  ?>	
	  
<div class="followimage">
<a href="/test/profileinserttest.php?ID=<?php echo $row['follow_user_id']; ?>"><img src="/test/images/<?php echo $row['logo']; ?>" alt="<?php echo $row['company']; ?>" /></a>
			 	</div>

<?php
}

	  ?>
</div>




This crashes with an error:

Code:
<div class="followbuttonimagearea">
												<?php
$query = mysql_query("SELECT * FROM follow JOIN users WHERE user_id = " . ($row['id']) . " ORDER BY follow_user_id ASC LIMIT 10");
while($row = mysql_fetch_array($query)) {
                 
	  ?>	
	  
<div class="followimage">
<a href="/test/profileinserttest.php?ID=<?php echo $row['follow_user_id']; ?>"><img src="/test/images/<?php echo $row['logo']; ?>" alt="<?php echo $row['company']; ?>" /></a>
			 	</div>

<?php
}

	  ?>
</div>


	  <div class="followbuttonimagearea">
												<?php
$query = mysql_query("SELECT * FROM follow JOIN users WHERE user_id = " . ($row['id']) . " ORDER BY follow_user_id ASC LIMIT 10");
while($row = mysql_fetch_array($query)) {     
	  ?>	
	  
<div class="followimage">
<a href="/test/profileinserttest.php?ID=<?php echo $row['follow_user_id']; ?>"><img src="/test/images/<?php echo $row['logo']; ?>" alt="<?php echo $row['company']; ?>" /></a>
			 	</div>

<?php
}

	  ?>
</div>