title: how to make my variable safe for database insertion?
body: <p>I have a variable which I need to strip of sybols before inserting into my database, any ideas how I would add the mysql_real_escape_string() function to my existing code?</p>
  
  <p>Form page</p>
  
  <p>This page is a basic html form which shows the database content.</p>
  
  <pre><code>&lt;?php 
   $query = sprintf( "SELECT * FROM sitecontent WHERE ID = $_GET[id]");
  $result = mysql_query($query) or die (mysql_error());
  $post = mysql_fetch_array($result);
  
     ?&gt;
  
         &lt;form action="editp.php" method="POST" name="editform"&gt;
      &lt;label for="pName" style="padding:10px; "&gt;Post Title&lt;/label&gt;
      &lt;input type="text" name="pName" style=" width:550px;border:#000099; margin:10px;"   value="&lt;?php echo $post['Post_Title']; ?&gt;"/&gt;
      &lt;label for="pCategory" style="padding:10px; "&gt;Category&lt;/label&gt;
      &lt;input type="text" name="pCategory" style=" width:50px;border:#000099; margin:10px;" value="&lt;?php echo $post['Post_Year']; ?&gt;"/&gt;
      &lt;label for="pItem" style="padding:10px;"&gt;Item Type&lt;/label&gt;
     &lt;select name="pItem" style="border:#000099; margin:10px;"&gt;
      &lt;option value="1"&gt;News&lt;/option&gt;
     &lt;option value="2"&gt;Review&lt;/option&gt;
   &lt;/select&gt;
   &lt;label for="pName" style="padding:10px;"&gt;Article ID&lt;/label&gt;
        &lt;input type="text" name="pID" style="border:#000099; margin:10px;" value="&lt;?php echo $post['ID']; ?&gt;"/&gt;
    &lt;label for="pName" style="padding:10px;"&gt;Post Date&lt;/label&gt;
     &lt;input type="text"  name="pDate" style="border:#000099; margin:10px;" value="&lt;?php echo $post['Date']; ?&gt;"&gt;
     &lt;label for="pName" style="padding:10px;"&gt;Post Author&lt;/label&gt;
   &lt;input type="text" name="pAuthor" style="border:#000099; margin:10px;" value="&lt;?php echo $post['Post_Author']; ?&gt;"/&gt;
     &lt;label for="pName" style="padding:10px;"&gt;Home Page&lt;/label&gt;
    &lt;select name="Page" style="border:#000099; margin:10px;"&gt;
    &lt;option value="0"&gt;None&lt;/option&gt;
    &lt;option value="1"&gt;Home&lt;/option&gt;
   &lt;/select&gt;
   &lt;label for="pPriority" style="padding:10px;"&gt;Home Priority&lt;/label&gt;
     &lt;select name="pPriority" style="border:#000099; margin:10px;"&gt;
   &lt;option value="0"&gt;None&lt;/option&gt;
    &lt;option value="1"&gt;1&lt;/option&gt;
    &lt;option value="2"&gt;2&lt;/option&gt;
    &lt;option value="3"&gt;3&lt;/option&gt;
    &lt;option value="4"&gt;4&lt;/option&gt;
    &lt;/select&gt;
      &lt;label for="pName" style="padding:10px;"&gt;Post Content&lt;/label&gt;
    &lt;textarea style="width:550px; height:200px;border:#000099; margin:10px;" type="text" name="pContent" id="pContent" value="&lt;?php echo $post['Post_Content']; ?&gt;"&gt;&lt;?php echo $post['Post_Content']; ?&gt;&lt;/textarea&gt;
      &lt;span id="btnStrong" style="  padding: 2px 8px;background-color:#C00;font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; color:#FFF; cursor:pointer;"&gt;Bold&lt;/span&gt; &amp;nbsp; &lt;span id="btnItalic" style=" padding: 2px 8px; background-color:#C00;font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; color:#FFF; cursor:pointer;"&gt;Italic&lt;/span&gt;
     &lt;label for="pImage_Name" style="padding:10px;"&gt;Image Name&lt;/label&gt;
     &lt;input type="text" name="pImage_Name" style="border:#000099; margin:10px; width:550px;" value="&lt;?php echo $post['Image_Name']; ?&gt;"/&gt;
     &lt;label for="pApproval" style="padding:10px;"&gt;Approval&lt;/label&gt;
     &lt;select name="pApproval" style="border:#000099; margin:10px;"&gt;
    &lt;option value="0"&gt;Pending&lt;/option&gt;
    &lt;option value="1"&gt;Approved&lt;/option&gt;
    &lt;/select&gt;
     &lt;input type="hidden" name="id" value="&lt;?php echo $_GET['id']; ?&gt;"/&gt;
       &lt;span style="margin-left:10px;"&gt;Please check the changes above before submitting&lt;/span&gt;                &lt;br/&gt;
     &lt;input type="submit" name="go" value="Submit Changes" style=" padding: 2px 8px;background-color:#C00; color:#FFF; margin:10px;"/&gt;
     &lt;/form&gt;
  
     &lt;?php
  $updateq = "UPDATE sitecontent WHERE ID = '$_POST[id]'";
     ?&gt;
  </code></pre>
  
  <p>Update page</p>
  
  <p>This is the page that writes the content from the form to the database.</p>
  
  <pre><code>    &lt;?php
   include'includes/connection.php';
   $pName = $_POST['pName'];
   $pItem = $_POST['pItem'];
   $pCategory = $_POST['pCategory'];
   $pDate = $_POST['pDate'];
   $pAuthor = $_POST['pAuthor'];
   $pContent = $_POST['pContent'];
   $Page = $_POST['Page'];
   $id = $_POST['id'];
   $pApproval = $_POST['pApproval'];
   $pPriority = $_POST['pPriority'];
   $pImage_Name = $_POST['pImage_Name'];
  
   $updateq = "UPDATE sitecontent SET ID = '$pID', Post_Title = '$pName', Post_Year =      '$pCategory', Date = '$pDate', Post_Author = '$pAuthor', Post_Content = '$pContent', Page =      '$Page', Post_Approval = '$pApproval', Priority = '$pPriority', Image_Name = '$pImage_Name'      WHERE ID = '$_POST[id]'";
  
   $result = mysql_query($updateq) or die (mysql_error());
   header("Location:admin.php");
  
   ?&gt;
  </code></pre>