title: Request a select option in php
body: <p>I am looking for a possibility to include a select option in a database. For some reason the value doesn't show up in the POST function of the sound_upload.php. I always get the mysql message "category can't be null". Is this problem connected to the use of the jascript or did I simply use the wrong php code?</p>
  
  <p><strong>Upload.php</strong></p>
  
  <pre><code>    &lt;?php
      require_once('auth.php');
  ?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
  &lt;title&gt;My Profile&lt;/title&gt;
  &lt;link href="loginmodule.css" rel="stylesheet" type="text/css" /&gt;
  &lt;script type="text/javascript" src="./../../src/jquery-1.6.1.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="./../../src/jquery.relatedselects.min.js"&gt;&lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
  $(function(){
  
      $("#categories").relatedSelects({
          onChangeLoad: 'datasupplier.php',
          selects: ['categoryID', 'subcategoryID']
      });
  
  });
  &lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;Upload&lt;/h1&gt;
  &lt;a href="profile.php"&gt;My Profile&lt;/a&gt; | &lt;a href="upload.php"&gt;Upload&lt;/a&gt; | &lt;a href="http://www.soundypedia.com/index.php"&gt;Logout&lt;/a&gt;
  &lt;p&gt;
  &lt;form action="sound_upload.php" method="post" id="categories" enctype="multipart/form-data"&gt;
          &lt;table align="center"&gt;
                  &lt;tr valign="baseline"&gt;
                          &lt;td nowrap="nowrap" align="right"&gt;Title: &lt;/td&gt;
                          &lt;td&gt;&lt;input type="text" name="title" value="" size="32" /&gt;&lt;/td&gt;
                  &lt;/tr&gt;
  
                      &lt;tr valign="baseline"&gt;
                              &lt;td nowrap="nowrap" align="right"&gt;Category: &lt;/td&gt;
                              &lt;td&gt;
                                  &lt;select name="categoryID"&gt;
                                      &lt;option value=""&gt;Category&lt;/option&gt;
                                      &lt;option value="Natural"&gt;Natural&lt;/option&gt;
                                      &lt;option value="Urban"&gt;Urban&lt;/option&gt;
                                      &lt;option value="Musical"&gt;Musical&lt;/option&gt;
                                      &lt;option value="Abstract"&gt;Abstract&lt;/option&gt;
                                      &lt;option value="Signals"&gt;Signals&lt;/option&gt;
                                  &lt;/select&gt;
                              &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr valign="baseline"&gt;
                              &lt;td nowrap="nowrap" align="right"&gt;Subcategory: &lt;/td&gt;
                              &lt;td&gt;
                                  &lt;select name="subcategoryID"&gt;
                                      &lt;option value=""&gt;Subcategory&lt;/option&gt;
                                  &lt;/select&gt;
                              &lt;/td&gt;
                      &lt;/tr&gt;
  
                  &lt;tr valign="baseline"&gt;
                          &lt;td nowrap="nowrap" align="right"&gt;Keywords: &lt;/td&gt;
                          &lt;td&gt;&lt;input type="text" name="keywords" value="" size="32" /&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr valign="baseline"&gt;
                          &lt;td nowrap="nowrap" align="right"&gt;Upload: &lt;/td&gt;
                          &lt;td&gt;&lt;label&gt;
                          &lt;input type="file" name="upload" id="upload" /&gt;
                          &lt;?php   // Configuration - Your Options
                              $allowed_filetypes = array('.mp3','.mid','.m4a'); // These will be the types of file that will pass the valartistation.
                              $max_filesize = 5242880; // Maximum filesize in BYTES (currently 5.0 MB).
                              $upload_path = './../../sounds/'; // The place the files will be uploaded to (currently a 'files' directory).
                              $filename = $_FILES['upload']['name']; // Get the name of the file (including file extension).
                              $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Get the extension from the filename.
  
                                  // Upload the file to your specified path.
                              if(move_uploaded_file($_FILES['upload']['tmp_name'],$upload_path . $filename))?&gt;
                          &lt;/label&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr valign="baseline"&gt;
                  &lt;td&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="submit" name="submit" class="submit" /&gt;&lt;/td&gt;
  
          &lt;/table&gt;
          &lt;div id="hide"&gt;
              &lt;input type="text" name="artist" value="&lt;?php echo $_SESSION['SESS_FIRST_NAME']; echo ' '; echo $_SESSION['SESS_LAST_NAME'];?&gt;"/&gt;
              &lt;input type="hartistden" name="date" value="&lt;?php echo date("d.m.Y"); ?&gt;" /&gt;
              &lt;input type="hartistden" name="ip" value="&lt;?php echo $_SERVER['REMOTE_ADDR']; ?&gt;" /&gt;
          &lt;/div&gt;
  
  &lt;/form&gt;
  &lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>sound_upload.php</strong></p>
  
  <pre><code>&lt;?php require_once('sound_database.php'); ?&gt;
  &lt;?php
  if (!function_exists("GetSQLValueString")) {
  function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
  {
    if (PHP_VERSION &lt; 6) {
      $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
    }
  
    $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  
    switch ($theType) {
      case "text":
        $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
        break;    
      case "long":
      case "text":
        $theValue = ($theValue != "") ? textval($theValue) : "NULL";
        break;
      case "double":
        $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
        break;
    }
    return $theValue;
  }
  }
  
  $editFormAction = $_SERVER['PHP_SELF'];
  if (isset($_SERVER['QUERY_STRING'])) {
    $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  }
  
  if (isset($_POST["submit"])) {
    $insertSQL = sprintf("INSERT INTO sounds (id, title, artist, category, subcategory, keywords, upload, download, rating, ip, date) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                         GetSQLValueString($_POST['id'], "text"),
                         GetSQLValueString($_POST['title'], "text"),
                         GetSQLValueString($_POST['artist'], "text"),
                         GetSQLValueString($_POST['category'], "text"),
                         GetSQLValueString($_POST['subcategory'], "text"),
                         GetSQLValueString($_POST['keywords'], "text"),
                         GetSQLValueString($_FILES['upload']['name'], "text"),
                         GetSQLValueString($_POST['download'], "text"),
                         GetSQLValueString($_POST['rating'], "text"),
                         GetSQLValueString($_POST['ip'], "text"),
                         GetSQLValueString($_POST['date'], "text"));
  
    mysql_select_db($database_test, $test);
    $Result1 = mysql_query($insertSQL, $test) or die(mysql_error());
  }
  ?&gt;
  &lt;?php
  $Anzahl = mysql_affected_rows();
      if ($Anzahl&gt;0)
      {
        echo 'Your sound upload has been successful!&lt;br&gt;To go back click &lt;a href="upload.php"&gt;here&lt;/a&gt;';
      }
      else
      {
        echo 'An error has occured! Your upload has not been saved.&lt;br&gt;To go back click &lt;a href="upload.php"&gt;here&lt;/a&gt;';
      }
  ?&gt;
  &lt;link href="loginmodule.css" rel="stylesheet" type="text/css" /&gt;
  </code></pre>