Syntax for dynamic dropdown in form

I have a simple database structure with a table for venues and events.

I am trying to add a select drop down in my form to add a new event which lists the venues, and inserts the VenueID into a field in the Events table.

I have this, which I think is pretty close, but its not pulling anything through:

<select name="VenueID">
    $sql = "SELECT VenueID, Venue FROM Venues ORDER BY Venue ASC";
    $result = mysql_query($sql);
    while ($row = mysql_fetch_array($result)) {
    echo '<option value="' . $row['VenueID'] . '">' . $row['Venue'] . '</option>';

Apologies if this is more a mySQL question - this sort of thing always seem to fall between the two.

Thanks for any pointers.

Thanks, and a good spot - unfortunately that was just a typo here, not in my original code.

so in your code there is no drop downlist displayed?

change this

while ($row = mysql_fetch_array($result))

to this

while ($row = mysql_fetch_array($result,MYSQL_BOTH))

Thanks, but still no joy.

The drop down is there, but empty.

I have a reference to the DB connection in the header, so assume it doesn’t need anything else up in the header?

Just to say I have it working now by explicitly referencing the DB again, i.e. adding:

mysql_connect(‘localhost’, ‘username’, ‘password’);

A connection file was referenced in the header but must have needed that too.