title: Returning json_encode as array not working
body: <p>Here is my button</p>
  
  <pre><code>$( "#editVehicle" ).button().click(function( event ) {
  
      event.preventDefault();
      var vp = $("input[name=vehicle_plate]").val(),
      dataString = 'vehicle_plate='+ vp;
  
      $.ajax({
          type: "POST",
          url: "editvehicle.php",
          data: dataString,
          dataType: "json",
          success: function(data){
              if(!data.error &amp;&amp; data.success) {
                  $("input[name=vehicle_model]").val(data.vehicleName);
                  $("input[name=assigned_driver]").val(data.assignedDriver);
              } else {
                  alert(data.errorMsg);
              }
          }
      });
  
  });
  </code></pre>
  
  <p>And here is my PHP</p>
  
  <pre><code>&lt;?PHP
  include("db.classes.php");
  $g = new DB();
  $g-&gt;connection();
  
  if($_POST) {
      $vehiclePlate = $g-&gt;clean($_POST["vehicle_plate"],1);
      $g-&gt;edit($vehiclePlate);
  }
  $g-&gt;close();
  ?&gt;
  </code></pre>
  
  <p>and here is my db.classes</p>
  
  <pre><code>public function edit($vehiclePlate)
  {
      $sql = "select vehicle_name, driver_id from vehicles where vehicle_plate='$vehiclePlate'";
  
      $result = mysql_query($sql) or die(json_encode(array("error" =&gt; 0, "errorMsg" =&gt; "MySQL query failed.")));
      $row = mysql_fetch_array($result);
  
      if(mysql_num_rows($row)) {
          echo json_encode(array(
              "success" =&gt; 1,
              "vehicleName" =&gt; $row['vehicle_name'],
              "assignedDriver" =&gt; $row['driver_id']
          ));
      } 
      else {
          echo json_encode(array(
              "error" =&gt; 1,
              "errorMsg" =&gt; "No rows returned"
          ));
      }
  
  }
  </code></pre>
  
  <p>button tag</p>
  
  <pre><code>&lt;button type="submit" id="editVehicle" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"&gt;
      &lt;span class="ui-button-text"&gt;Edit&lt;/span&gt;
  &lt;/button&gt;
  </code></pre>
  
  <p>There is an input field in my html where i input the vehicle plate then when the user clicks the button the program searches the database for the vehicle name and driver_id with the plate the user entered and returns the value to another inputfield named <strong>"vehicle_name"</strong> and <strong>"assigned_driver"</strong> but nothing is happening when the button is clicked not even the error alert message. Any idea on where am i going wrong here?</p>