Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getLastErrno() not working #996

Open
Brecht272727 opened this issue Sep 29, 2022 · 1 comment
Open

getLastErrno() not working #996

Brecht272727 opened this issue Sep 29, 2022 · 1 comment

Comments

@Brecht272727
Copy link

Brecht272727 commented Sep 29, 2022

Hi, i using the latest version of MysqlDb.php
I am using ajax with dataType 'json'. But i can't see the error message in console.
See below for the ajax code i use:

if($_POST) {
  
  include('../lib/connection.php');
  
  $cname = $_REQUEST['cname'];
  $street = $_REQUEST['street'];
  $postal = $_REQUEST['postal'];
  $city = $_REQUEST['city'];
  $country = $_REQUEST['country'];
  $phone = $_REQUEST['phone'];
  
  if(empty($cname)) {
    $cname = NULL;
  }
  
  $data = array(
      'cname' => $cname,
      'street' => $street,
      'postal' => $postal,
      'city' => $city,
      'country' => $country,
      'phone1' => $phone,
      'status' => 1,
      'created' => date('Y-m-d H:i:s')
  );
  
  $db->insert('addresses', $data);
  
  if($db->getLastErrno() === 0) {
    $res = array('success' => true, 'message' => 'Leveringsadres toegevoegd');
  } else {
    $res = array('error' => true, 'message' => 'Leveringsadres niet toegevoegd: '.$db->getLastError());
  }
  
  echo json_encode($res);
  
}
            $.ajax({
                type: 'POST',
                url: 'assets/ajax/save-deliveryform.php',
                dataType: 'json',
                cache: false,
                data: $('.deliveryForm').serialize(), 
                success: function (data) {
                  console.log(data);
                },
                error: function (xhr, status, error) {
                    console.log('An error occurred');
                    var err = eval("(" + xhr.responseText + ")");
                    console.log(err);
                }
            });
@Brecht272727
Copy link
Author

Brecht272727 commented Sep 30, 2022

@avbdr or @ThingEngineer ? Any solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant