Hi there!
Try the following, hints remeber to annotate as much as possible, split your code up makes it easier to run through (if something does not work post me back!):
$code1 = $_POST['code'];
$claim1 = "SELECT * FROM credits WHERE r_code = '$code1' ";
$claim = mysql_query($claim1);
if($claim) { // query has sucessful
$num_results = mysql_num_rows($claim); // returns number of rows returned from query
for($i=0; $i<$num_results; $i++){ // runs through the results
$row = mysql_fetch_assoc($claim); // can go through result array using names
if($row['r_code'] == '$code1' && $row['claim'] == 'y') {
print"This Receipt Code has already been claimed!";
}
if($row['r_code'] == '$code1' && $row['claim'] == 'n') {
$new_query = " UPDATE credits SET claim = 'y' WHERE r_code = '$code1' ";
$query2 = mysql_query($new_query);
if($query2){
echo 'Update of database successful.<br><br>';
}
else{
echo 'Could not update the databse.<br><br>';
}
} // to seconf if of first successgul query
} // to the for going through results
} // to if first query successful
else{
echo 'Could not find all from table credits in database. The query failed.<br><br>';
}