title: Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, string given
body: <p>I have a secured area of my site where I can add/update/delete database entries.  I am trying to update the script from mysql to mysqli.  Everything works except for the "update" part.  When I fill in the new information and click "update", it gives me this error: </p>
  
  <blockquote>
    <p>Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli,
    string given in
    /home3/tarb89/public_html/aususrpg.net/charbase/updated.php on line 19</p>
  </blockquote>
  
  <p>I'm not sure what is wrong here; I'm a complete newbie, so my apologies.  </p>
  
  <p>Here is my update.php code:</p>
  
  <pre><code>&lt;?php
      // Create connection
  $con=mysqli_connect("xxx","xxx","xxx","xxx");
  
  // Check connection
  if (mysqli_connect_errno())
    {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
  
  
  $id = $_GET['id'];
  
  $result = mysqli_query($con,"SELECT * FROM characters WHERE id = '$id'");
  $my_array = array($c_z);
  extract($my_array);
  
  ?&gt;
  
  &lt;form id="FormName" action="../charbase/updated.php" method="post" name="FormName"&gt;
  &lt;table width="448" border="0" cellspacing="2" cellpadding="0"&gt;
  
  &lt;tr&gt;
  &lt;td width="150" align="right"&gt;&lt;label for="name"&gt;Name: &lt;/label&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input name="name" maxlength="255" type="text" value="&lt;?php echo stripslashes($name) ?&gt;"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td colspan="2" align="center"&gt;
  &lt;input name="" type="submit" value="Update"&gt;
  &lt;input name="id" type="hidden" value="&lt;?php echo $id ?&gt;"&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The other issue I have with the update.php page is when it displays the table, the inputs should display the information already listed in the database; currently, it shows the name field but the input section is empty.  It should display the name data already in the database (then I can replace it with whatever I want it to update as.)</p>
  
  <p>Here is the updated.php code:</p>
  
  <pre><code>&lt;?php
  // Create connection
  $con=mysqli_connect("xxx","xxx","xxx","xxx");
  
  // Check connection
  if (mysqli_connect_errno())
    {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
  
  $id = $_POST['id'];
  
  $name = mysqli_real_escape_string(trim($_POST["name"]), $con);
  
  $rsUpdate = mysqli_query($con,"UPDATE characters SET name='$name'
  WHERE id='$id'");
  
  if($rsUpdate) { echo "Successfully updated"; } else { die('Invalid query: '.mysql_error()); }
  ?&gt;
  
  &lt;a href="index.php"&gt;Back to index&lt;/a&gt;
  </code></pre>
  
  <p>Any help would be greatly appreciated.  This thing is driving me bonkers.</p>
  
  <hr>
  
  <p><strong>Different issue:  see above update.php code.</strong></p>
  
  <p>When I click on a link next to a database entry, called "Update Information", it takes me to update.php?id=charactersid</p>
  
  <p>Currently, it displays an empty input form.  I can input information and hit "update" and it WILL update correctly.</p>
  
  <p>However, when I am taken to the update.php page, I want it to display the input form except the values should all equal what is already in the database.</p>
  
  <p>For example:</p>
  
  <p>What it currently shows:</p>
  
  <p>Name: [empty input box]</p>
  
  <p>What I want it to show:</p>
  
  <p>Name: [current name listed in the database]</p>
  
  <p>So the value of the input should be the information for that character; so that when I want to update, I can see what is already listed as information for that character and change/delete/add whatever else I need to.</p>
  
  <p>Does that make more sense?</p>