title: mysqli_real_escape_string correct syntax when using CASE for inserting to db
body: <p>im having syntax errors thrown back at me when using mysqli_real_escape_string. The IDE that i am using shows no syntax issues, however this is the first time i have tried using this function with multiple CASE statements (infact i have not used this function very much at all).</p>
  
  <p>The insertion code is here:</p>
  
  <pre><code>$query = "INSERT INTO `auctionwp_categories` 
           (`CategoryID`, `CategoryLevel`, `CategoryName`, `CategoryParentID`, `LeafCategory`, `AutoPayEnabled`, `BestOfferEnabled`, `Expired`, `IntlAutosFixedCat`, `Virtual`, `LSD`, `ORPA`)
    VALUES (
            '".mysqli_real_escape_string($link, $xmlCategoryID)."', '".mysqli_real_escape_string($link, $xmlCategoryLevel).", '".mysqli_real_escape_string($link, $xmlCategoryName).", '".mysqli_real_escape_string($link, $xmlCategoryParentID).",
            CASE '".mysqli_real_escape_string($link, $xmlLeafCategory)."' WHEN 'true' THEN 1 ELSE 0 END,
            CASE '".mysqli_real_escape_string($link, $xmlAutoPayEnabled)."' WHEN 'true' THEN 1 ELSE 0 END,
            CASE '".mysqli_real_escape_string($link, $xmlExpired)."' WHEN 'true' THEN 1 ELSE 0 END,
            CASE '".mysqli_real_escape_string($link, $xmlBestOfferEnabled)."' WHEN 'true' THEN 1 ELSE 0 END,
            CASE '".mysqli_real_escape_string($link, $xmlIntlAutosFixedCat)."' WHEN 'true' THEN 1 ELSE 0 END,
            CASE '".mysqli_real_escape_string($link, $xmlVirtual)."' WHEN 'true' THEN 1 ELSE 0 END,
            CASE '".mysqli_real_escape_string($link, $xmlLSD)."' WHEN 'true' THEN 1 ELSE 0 END,
            CASE '".mysqli_real_escape_string($link, $xmlORPA)."' WHEN 'true' THEN 1 ELSE 0 END
            )";
  
  if (mysqli_query($link, $query)) {
  echo "Successfully inserted " . mysqli_affected_rows($link) . " row";
  } else {
  echo "Error occurred: " . mysqli_error($link);
  }
  </code></pre>
  
  <p>Connection to db is successfull via this code in a config file:</p>
  
  <pre><code>$user="root";
  $pass="";
  $database="auctionwp";
  $server="localhost";
  
  $link = mysqli_connect($server, $user, $pass, $database);
  
  if (!$link) {
  die('Connect Error (' . mysqli_connect_errno() . ') '
          . mysqli_connect_error());
  }
  
  echo 'Success... ' . mysqli_get_host_info($link) . "\n";
  </code></pre>
  
  <p>Is my problem of syntax due to the CASE statements? i can find no examples online or in php manual that show mysqli_real_escape_string being used on insertion with this statement,</p>
  
  <p>regards
  Martin</p>