You need always check your query succeeded and returns some records before you try and use it. You can also catch any errors and debug them a little better.
<?php
$sql = "SELECT AND SHOW COLUMNS FROM `members` WHERE field='Lens' AND username LIKE '$username'";
if ($result = mysql_query($sql))) {
if (mysql_num_rows($result)) {
while ($row = mysql_fetch_row($result)) {
echo '<select name="lens" style="margin-left:10px; width: 200px; font-size:11px"/>';
echo "<option value=\"0\">Please Select...</option>";
foreach (explode("','",substr($row[1],6,-2)) as $v) {
print "<option value=\"".$v."\"";
if (isset($_POST['Lens']) && $_POST['Lens']==$v) {
print ' selected';
print ">$v</option>";
}
}
echo '</select>';
}
} else {
// no results found.
}
} else {
trigger_error(mysql_error() . "<br />" . $sql);
}
?>
If your expecting more than one result your html is going to be foobar'd. If your not expecting more than one result, you don't need the while loop and should probably put a LIMIT clause in your query.