Why isn't this code updating my db?

Hmmm, I can’t understand what is wrong here.

The following code is listing my data on the screen (as a test), but it’s not updating the random code to my db. Why not?

<?php do { ?>
//Random code generator
$obj3 = new Random(false, true, true);
$randcode = $obj3->get(8);

$idnr = ($row_rs_test['test_id']);

mysql_query("UPDATE test SET random = $randcode
WHERE test_id = $idnr");

echo $row_rs_test['station']; ?> | <?php echo $randcode; ?><br />
<?php } while ($row_rs_test = mysql_fetch_assoc($rs_test)); ?>

I found the answer myself now. Changed the UPDATE to:

$query = "UPDATE test SET random = '$randcode' WHERE test_id = '$idnr'";
$result = mysql_query($query) or die ("Unable to execute query: " . mysql_error());

Now it’s working

Have you checked mysql_error* to see why?