title: PHP Update MySQL Column is empty
body: <p>I have php page that you can type in a number and then click the submit button and it should update the column in the table.
  The problem I have is that it isn't updating the value but just leaving an empty field.</p>
  
  <p>Something seems to be wrong with this line.</p>
  
  <pre><code>$update = mysql_query("UPDATE sip SET callerid = '$new' WHERE name = $trial");
  </code></pre>
  
  <p>If I just change the $new to a number it works fine. If I echo $new I get a number. Also the $trial bit works fine.</p>
  
  <p>The full code I have is below.</p>
  
  <pre><code>   &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Test&lt;/title&gt;
  &lt;link href="/../site.css" rel="stylesheet"&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;? include("../header.php") ?&gt;  
  &lt;div id="main"&gt;
  
  
  &lt;?php
  session_start();
  $trial = $_SESSION['random'];
  echo "Random: ".$trial;
  
  if(empty($_SESSION['random'])) {
  header("Location:/site/home.php");
  }
  
     echo "&lt;br /&gt;";
  ?&gt;
  
      &lt;form action="customer_details.php" method="post"&gt;
      Number: &lt;input type="number" name="phone" id="phone" maxlength="4" min="1000" max="9999" /&gt;
       &lt;br /&gt;&lt;br /&gt;
      &lt;input type="Submit" /&gt;
  
  &lt;/form&gt;
  
  
  &lt;?php
  $link = mysql_connect('localhost', 'root', '');
  mysql_select_db('test' , $link) or die("Unable to select database: asterisk" . mysql_error());
  
  
  if(isset($_POST['phone']))
  {
  
  $phone = $_POST['phone'];
  
  
  
  $result = mysql_query("SELECT * FROM table where number = '$phone'");
  while ($row = mysql_fetch_array($result)) 
  {
  
  $data = $row['callerid'];
  }
  
  echo $phone;
  
  if($phone = $data)
  {
  
  print '&lt;script type="text/javascript"&gt;'; 
  print 'alert("Number is already in database")'; 
  print '&lt;/script&gt;';
  
  }
  else {
  $new = $phone;
  $update = mysql_query("UPDATE sip SET callerid = '$new' WHERE name = $trial");
  
  if(! $update )
  {
    die('Could not update data: ' . mysql_error());
  }
  else
  {
  print '&lt;script type="text/javascript"&gt;'; 
  print 'alert("New Data added");'; 
  print 'window.location.href = "../home.php";';
  print '&lt;/script&gt;';
  }
  
  }
  
  }
  ?&gt;
  
  &lt;? include("../footer.php") ?&gt; 
  &lt;/div&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>