title: cannot create database using mySQLi
body: <p>I'm always getting error when inserting the value to my database. but it's working when i'm using mySQL only, I'm new to SQLi so please be gentel.</p>
  
  <p>insert.php</p>
  
  <pre><code>    &lt;?php
      include("dbinfo.inc.php");
  
      //connect to mysql server
      $mysqli = new mysqli("localhost", $username, $password, $database);
  
      //check if any connection error was encountered
      if(mysqli_connect_errno()) {
          echo "Error: Could not connect to database.";
          exit;
      }     
  
      //insert    
      $query = "insert into client_info set (
      id = '".$mysqli-&gt;real_escape_string('')."',
      first = '".$mysqli-&gt;real_escape_string($_POST['first'])."',
      last = '".$mysqli-&gt;real_escape_string($_POST['last'])."',
      phone = '".$mysqli-&gt;real_escape_string($_POST['phone'])."',
      mob = '".$mysqli-&gt;real_escape_string($_POST['mob'])."',
      fax = '".$mysqli-&gt;real_escape_string($_POST['fax'])."',
      email = '".$mysqli-&gt;real_escape_string($_POST['email'])."',
      web = '".$mysqli-&gt;real_escape_string($_POST['web'])."',
      com = '".$mysqli-&gt;real_escape_string($_POST['com'])."',
      address = '".$mysqli-&gt;real_escape_string($_POST['address'])."',
      city = '".$mysqli-&gt;real_escape_string($_POST['city'])."',
      state = '".$mysqli-&gt;real_escape_string($_POST['state'])."',
      zip = '".$mysqli-&gt;real_escape_string($_POST['zip'])."',
      zone = '".$mysqli-&gt;real_escape_string($_POST['zone'])."',
      office = '".$mysqli-&gt;real_escape_string($_POST['office'])."',
      office_num = '".$mysqli-&gt;real_escape_string($_POST['office_num'])."',
      ext_mob = '".$mysqli-&gt;real_escape_string($_POST['ext_mob'])."',
      ext_phone = '".$mysqli-&gt;real_escape_string($_POST['ext_phone'])."',
      ext_office = '".$mysqli-&gt;real_escape_string($_POST['ext_office'])."',
      srv = '".$mysqli-&gt;real_escape_string($_POST['srv'])."',
      stype = '".$mysqli-&gt;real_escape_string($_POST['stype'])."',
      voip = '".$mysqli-&gt;real_escape_string($_POST['voip'])."',
      vpass = '".$mysqli-&gt;real_escape_string($_POST['vpass'])."',
      regDate = '".$mysqli-&gt;real_escape_string($_POST['regDate'])."',
      acct = '".$mysqli-&gt;real_escape_string($_POST['acct'])."',
      Nagents = '".$mysqli-&gt;real_escape_string($_POST['Nagents'])."',
      agents = '".$mysqli-&gt;real_escape_string($_POST['agents'])."',
      password = '".$mysqli-&gt;real_escape_string($_POST['password'])."'
      )";
  
          //execute the query
          if( $mysqli-&gt;query($query) ) {
              //if saving success
              echo "User was created.";
          }else{
              //if unable to create new record
              echo "Database Error: Unable to create record.";
          }
          //close database connection
          $mysqli-&gt;close();
  
  
      ?&gt;
  </code></pre>
  
  <p>create.php</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;script language="JavaScript"&gt;
  var today=new Date();
  var jran=today.getTime();
  
  function random() {
      ia=9301;
      ic=49297;
      im=233280;
      jran = (jran*ia+ic) % im;
      return jran/(im*1.0);
  };
  
  function rand(number) {
      return Math.ceil(random()*number);
  };
  
  function makearray(n) {
      this.length = n;
      for (var i = 1; i &lt;= n; i++) this[i] = 0;
      return this;
  }
  
  var asciitable = new makearray (128);
  asciitable.length=128;
  for (var i=0;i&lt;=127;i++) asciitable[i]="";
  asciitable[33]="!"; asciitable[34]="\""; 
  asciitable[35]="#"; asciitable[36]="$";
  asciitable[37]="%"; asciitable[38]="&amp;"; 
  asciitable[39]="'"; asciitable[40]="(";
  asciitable[41]=")"; asciitable[42]="*"; 
  asciitable[43]="+"; asciitable[44]=",";
  asciitable[45]="-"; asciitable[46]="."; 
  asciitable[47]="/"; asciitable[48]="0";
  asciitable[49]="1"; asciitable[50]="2"; 
  asciitable[51]="3"; asciitable[52]="4";
  asciitable[53]="5"; asciitable[54]="6"; 
  asciitable[55]="7"; asciitable[56]="8";
  asciitable[57]="9"; asciitable[58]=":"; 
  asciitable[59]=";"; asciitable[60]="&lt;";
  asciitable[61]="="; asciitable[62]="&gt;"; 
  asciitable[63]="?"; asciitable[64]="@";
  asciitable[65]="A"; asciitable[66]="B"; 
  asciitable[67]="C"; asciitable[68]="D";
  asciitable[69]="E"; asciitable[70]="F"; 
  asciitable[71]="G"; asciitable[72]="H";
  asciitable[73]="I"; asciitable[74]="J"; 
  asciitable[75]="K"; asciitable[76]="L";
  asciitable[77]="M"; asciitable[78]="N"; 
  asciitable[79]="O"; asciitable[80]="P";
  asciitable[81]="Q"; asciitable[82]="R"; 
  asciitable[83]="S"; asciitable[84]="T";
  asciitable[85]="U"; asciitable[86]="V"; 
  asciitable[87]="W"; asciitable[88]="X";
  asciitable[89]="Y"; asciitable[90]="Z"; 
  asciitable[91]="["; asciitable[92]="\\";
  asciitable[93]="]"; asciitable[94]="^"; 
  asciitable[95]="_"; asciitable[96]="`";
  asciitable[97]="a"; asciitable[98]="b"; 
  asciitable[99]="c"; asciitable[100]="d";
  asciitable[101]="e"; asciitable[102]="f"; 
  asciitable[103]="g"; asciitable[104]="h";
  asciitable[105]="i"; asciitable[106]="j"; 
  asciitable[107]="k"; asciitable[108]="l";
  asciitable[109]="m"; asciitable[110]="n"; 
  asciitable[111]="o"; asciitable[112]="p";
  asciitable[113]="q"; asciitable[114]="r"; 
  asciitable[115]="s"; asciitable[116]="t";
  asciitable[117]="u"; asciitable[118]="v"; 
  asciitable[119]="w"; asciitable[120]="x";
  asciitable[121]="y"; asciitable[122]="z"; 
  asciitable[123]="{"; asciitable[124]="|";
  asciitable[125]="}"; asciitable[126]="~";
  
  function nchar(num) {
      if ((num&gt;=33) &amp;&amp; (num&lt;=127)) return asciitable[num];
  }
  
  function doit() {
      var i;
      var n;
      var s = "";
              for (i=1;i&lt;=8;i++) {
                  n=0;
                  while ( (n&lt;=47) || 
                                          ((n&gt;=58) &amp;&amp; (n&lt;=96)) || 
                                          (n&gt;=123))  n = rand(126);
                  s = s + nchar(n);
              }
  
      document.gen.password.value = s;
  }
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;form method="post" action="insert.php" name="gen"&gt;
  &lt;b&gt;Personal Info:&lt;/b&gt;
  &lt;p&gt;First Name:&lt;input type="text" name="first" size="20" /&gt;&lt;/p&gt;
  &lt;p&gt;Last Name:&lt;input type="text" name="last" size="20" /&gt;&lt;/p&gt;
  &lt;p&gt;Mob:&lt;input type="text" name="mob" size="20" /&gt;
  ext:&lt;input type="text" name="ext_mob" size="4" /&gt;&lt;/p&gt;
  &lt;p&gt;Phone:&lt;input type="text" name="phone" size="20" /&gt;
  ext:&lt;input type="text" name="ext_phone" size="4" /&gt;&lt;/p&gt;
  &lt;p&gt;Fax:&lt;input type="text" name="fax" size="20" /&gt;&lt;/p&gt;
  &lt;p&gt;E-mail:&lt;input type="text" name="email" size="35" /&gt;
  &lt;p&gt;Address:&lt;input type="text" name="address" size="40" /&gt;&lt;/p&gt;
  &lt;p&gt;City:&lt;input type="text" name="city" size="20" /&gt;&lt;/p&gt;
  &lt;p&gt;State:&lt;input type="text" name="state" size="20" /&gt;&lt;/p&gt;
  &lt;p&gt;Zip Code:&lt;input type="text" name="zip" size="5" /&gt;&lt;/p&gt;
  &lt;p&gt;Zone:&lt;input type="text" name="zone" size="5" /&gt;&lt;/p&gt;
  &lt;br&gt;
  
  &lt;b&gt;Office Info:&lt;/b&gt;
  &lt;p&gt;Company:&lt;input type="text" name="com" size="40" /&gt;&lt;/p&gt;
  &lt;p&gt;Office Address:&lt;input type="text" name="office" size="40" /&gt;&lt;/p&gt;
  &lt;p&gt;Office Num #:&lt;input type="text" name="office_num" size="15" /&gt;
  ext:&lt;input type="text" name="ext_office" size="4" /&gt;&lt;/p&gt;
  &lt;p&gt;Website:&lt;input type="text" name="web" size="30" /&gt;&lt;/p&gt;&lt;br&gt;
  &lt;b&gt;Account Info:&lt;/b&gt;
  &lt;p&gt;Registry Date:&lt;input type="text" name="regDate" size="30" /&gt;&lt;/p&gt;
  &lt;p&gt;Account:&lt;input type="text" name="acct" size="20" /&gt;&lt;/p&gt;
  &lt;p&gt;Service:&lt;input type="text" name="srv" size="15" /&gt;&lt;/p&gt;
  &lt;p&gt;Service Type:&lt;input type="text" name="stype" size="40" /&gt;&lt;/p&gt;
  &lt;p&gt;Number of Agents:&lt;input type="text" name="Nagents" size="3" /&gt;&lt;/p&gt;&lt;br&gt;
  
  
  &lt;b&gt;Agent Info:&lt;/b&gt;
  &lt;p&gt;Agents:&lt;input type="text" name="agents" size="40" /&gt;&lt;/p&gt;
  &lt;p&gt;VOID:&lt;input type="text" name="voip" size="20" /&gt;&lt;/p&gt;
  &lt;p&gt;VOIP Password:&lt;input type="text" name="vpass" size="20" /&gt;&lt;/p&gt;
  &lt;br&gt;
  
  &lt;input type="hidden" size="20" name="password"&gt;
  
  &lt;input type="submit" name="go" value="Insert to Database" onclick="doit()"&gt;
  &lt;/form&gt;
  
  
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>the error i get is when the scripts tries to insert the query to the DB</p>
  
  <p>"Database Error: Unable to create record."</p>
  
  <p>i tried to see if there are any output on my form, and there is, even tried to insert just one variable "first" still getting errors, don't know what I'm doing wrong here</p>