Update another table

Update another table

estudiosestudios Posts: 52Questions: 0Answers: 0
edited September 2013 in General
Allan

I need to update table "B" when table "A" is edited so, with your enormous help I did

if ( isset( $_POST['action'] ) && $_POST['action'] === 'edit' ) {
// Actualizo la nota
$res1 = $db->sql( "
UPDATE notas
SET fecha = '".$_POST['data']['fecha']."',
idproyecto = '".$_POST['data']['idproyecto']."',
usuario = '".$_SESSION['nombre_staff'] ."',
idcontacto = '".$_POST['data']['idcontacto']."'
WHERE id = ".$_POST['data']['idnota'].";
")
->fetch();

}

But seem that $_POST $_POST['data']['idproyecto'] and the other Posts are empty...Any advice?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    edited September 2013
    We talked previously about using JSONP - are you using JSONP here? If so, you can't use POST, its GET parameters only (thus making it unsuitable in some cases).

    Allan
  • estudiosestudios Posts: 52Questions: 0Answers: 0
    Nop, I could not use JSONP. I decide to stay with "echo json_encode( $out );" In the future, next step, we will improve the speed. Now I need to make it run.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Okay - I'd suggest adding something like `print_r($_POST);` to the PHP script. It will cause a JSON error, but that's okay, you know its coming! You'd look at the Ajax return in your browser's inspector and be able to see exactly what is in _POST (you should actually be able to see what is in there using the inspector - but the print_r will make it absolutely clear).

    Regards,
    Allan
This discussion has been closed.