Failed to load resource: the server responded with a status of 500 (Internal Server Error)

I’ve been reading through past Internal Server error and can’t find one that solves my problem.

So for the dining & dancing pleasure of Wapplers I submit my own quandary –

During the day I get a form that seems to work perfectly – then as I try to modify visual layout elements I get null, null values again on my test table that I am targetting with an INSERT to Database table from a POST Form.

The inspector console in Firefox shows me this error

This is the structure of the file being reported –

<?php
require('../../../dmxConnectLib/dmxConnect.php');


$app = new \lib\App();

$app->define(<<<'JSON'
{
  "settings": {
    "options": {}
  },
  "meta": {
    "options": {},
    "$_POST": [
      {
        "type": "number",
        "name": "reg_id"
      },
    
      {
        "type": "number",
        "name": "reg_event"
      },
      {
        "type": "number",
        "name": "reg_pharmacy"
      },
      {
        "type": "text",
        "name": "reg_type"
      },
      {
        "type": "number",
        "name": "reg_job"
      },
      {
        "type": "text",
        "name": "reg_gender"
      },
      {
        "type": "text",
        "name": "reg_title"
      },
      {
        "type": "text",
        "name": "reg_name_first"
      },
      {
        "type": "text",
        "name": "reg_name_last"
      },
      {
        "type": "text",
        "name": "reg_mail"
      },
      {
        "type": "text",
        "name": "reg_mobilefon"
      },
      {
        "type": "text",
        "name": "reg_attendet"
      }
    ]
  },
  "exec": {
    "steps": [
      "Connections/connectionkade",
      "DatabaseUpdater/insert/insert1"
    ]
  }
}
JSON
);
?>

The file in the “DatabaseUpdater/insert/insert1(.php)”

looks like this –

<?php
$exports = <<<'JSON'
{
  "name": "insert1",
  "module": "dbupdater",
  "action": "insert",
  "options": {
    "connection": "connectionkade",
    "sql": {
      "type": "insert",
      "values": [
        {
          "table": "registration_hotels",
          "column": "reg_event",
          "type": "number",
          "value": "{{$_POST.reg_event}}"
        },
        {
          "table": "registration_hotels",
          "column": "reg_pharmacy",
          "type": "number",
          "value": "{{$_POST.reg_pharmacy}}"
        },
        {
          "table": "registration_hotels",
          "column": "reg_type",
          "type": "text",
          "value": "{{$_POST.reg_type}}"
        },
        {
          "table": "registration_hotels",
          "column": "reg_job",
          "type": "number",
          "value": "{{$_POST.reg_job}}"
        },
        {
          "table": "registration_hotels",
          "column": "reg_gender",
          "type": "text",
          "value": "{{$_POST.reg_gender}}"
        },
        {
          "table": "registration_hotels",
          "column": "reg_title",
          "type": "text",
          "value": "{{$_POST.reg_title}}"
        },
        {
          "table": "registration_hotels",
          "column": "reg_name_first",
          "type": "text",
          "value": "{{$_POST.reg_name_first}}"
        },
        {
          "table": "registration_hotels",
          "column": "reg_name_last",
          "type": "text",
          "value": "{{$_POST.reg_name_last}}"
        },
        {
          "table": "registration_hotels",
          "column": "reg_mail",
          "type": "text",
          "value": "{{$_POST.reg_mail}}"
        },
        {
          "table": "registration_hotels",
          "column": "reg_mobilefon",
          "type": "text",
          "value": "{{$_POST.reg_mobilefon}}"
        },
        {
          "table": "registration_hotels",
          "column": "reg_attendet",
          "type": "text",
          "value": "{{$_POST.reg_attendet}}"
        }
      ],
      "table": "registration_hotels",
      "query": "INSERT INTO registration_hotels\n(reg_event, reg_pharmacy, reg_type, reg_job, reg_gender, reg_title, reg_name_first, reg_name_last, reg_mail, reg_mobilefon, reg_attendet) VALUES (:P1 /* {{$_POST.reg_event}} */, :P2 /* {{$_POST.reg_pharmacy}} */, :P3 /* {{$_POST.reg_type}} */, :P4 /* {{$_POST.reg_job}} */, :P5 /* {{$_POST.reg_gender}} */, :P6 /* {{$_POST.reg_title}} */, :P7 /* {{$_POST.reg_name_first}} */, :P8 /* {{$_POST.reg_name_last}} */, :P9 /* {{$_POST.reg_mail}} */, :P10 /* {{$_POST.reg_mobilefon}} */, :P11 /* {{$_POST.reg_attendet}} */)",
      "params": [
        {
          "name": ":P1",
          "type": "expression",
          "value": "{{$_POST.reg_event}}"
        },
        {
          "name": ":P2",
          "type": "expression",
          "value": "{{$_POST.reg_pharmacy}}"
        },
        {
          "name": ":P3",
          "type": "expression",
          "value": "{{$_POST.reg_type}}"
        },
        {
          "name": ":P4",
          "type": "expression",
          "value": "{{$_POST.reg_job}}"
        },
        {
          "name": ":P5",
          "type": "expression",
          "value": "{{$_POST.reg_gender}}"
        },
        {
          "name": ":P6",
          "type": "expression",
          "value": "{{$_POST.reg_title}}"
        },
        {
          "name": ":P7",
          "type": "expression",
          "value": "{{$_POST.reg_name_first}}"
        },
        {
          "name": ":P8",
          "type": "expression",
          "value": "{{$_POST.reg_name_last}}"
        },
        {
          "name": ":P9",
          "type": "expression",
          "value": "{{$_POST.reg_mail}}"
        },
        {
          "name": ":P10",
          "type": "expression",
          "value": "{{$_POST.reg_mobilefon}}"
        },
        {
          "name": ":P11",
          "type": "expression",
          "value": "{{$_POST.reg_attendet}}"
        }
      ]
    }
  },
  "meta": [
    {
      "name": "identity",
      "type": "text"
    },
    {
      "name": "affected",
      "type": "number"
    }
  ]
}
JSON;
?>

AND the actual PHP form that fails to insert posted values and creates that 500 error is this ----

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="bootstrap/4/cerulean/bootstrap.min.css">
<script src="dmxAppConnect/dmxAppConnect.js"></script>
<script src="js/jquery-3.3.1.slim.min.js"></script>
<link rel="stylesheet" href="fontawesome4/css/font-awesome.min.css">
</head>
<body is="dmx-app" id="kadepost">
<div class="container">
<div class="row">
<div class="col">
<form is="dmx-api-form" id="serverconnectform1" method="post" action="dmxConnect/api/hotel_insert/posthotels.php" dmx-generator="bootstrap4" dmx-form-type="vertical" dmx-on:success="serverconnectform1.reset()">
<div class="form-group">
  <label for="inp_reg_event">Reg event</label>
  <input type="number" class="form-control" id="inp_reg_event" name="reg_event" aria-describedby="inp_reg_event_help" placeholder="Enter Reg event">
</div>
<div class="form-group">
  <label for="inp_reg_pharmacy">Reg pharmacy</label>
  <input type="number" class="form-control" id="inp_reg_pharmacy" name="reg_pharmacy" aria-describedby="inp_reg_pharmacy_help" placeholder="Enter Reg pharmacy">
</div>
<div class="form-group">
  <label for="inp_reg_type">Reg type</label>
  <input type="text" class="form-control" id="inp_reg_type" name="reg_type" aria-describedby="inp_reg_type_help" placeholder="Enter Reg type">
</div>
<div class="form-group">
  <label for="inp_reg_job">Reg job</label>
  <input type="number" class="form-control" id="inp_reg_job" name="reg_job" aria-describedby="inp_reg_job_help" placeholder="Enter Reg job">
</div>
<div class="form-group">
  <label for="inp_reg_gender">Reg gender</label>
  <input type="text" class="form-control" id="inp_reg_gender" name="reg_gender" aria-describedby="inp_reg_gender_help" placeholder="Enter Reg gender">
</div>
<div class="form-group">
  <label for="inp_reg_title">Reg title</label>
  <input type="text" class="form-control" id="inp_reg_title" name="reg_title" aria-describedby="inp_reg_title_help" placeholder="Enter Reg title">
</div>
<div class="form-group">
  <label for="inp_reg_name_first">Reg name first</label>
  <input type="text" class="form-control" id="inp_reg_name_first" name="reg_name_first" aria-describedby="inp_reg_name_first_help" placeholder="Enter Reg name first">
</div>
<div class="form-group">
  <label for="inp_reg_name_last">Reg name last</label>
  <input type="text" class="form-control" id="inp_reg_name_last" name="reg_name_last" aria-describedby="inp_reg_name_last_help" placeholder="Enter Reg name last">
</div>
<div class="form-group">
  <label for="inp_reg_mail">Reg mail</label>
  <input type="text" class="form-control" id="inp_reg_mail" name="reg_mail" aria-describedby="inp_reg_mail_help" placeholder="Enter Reg mail">
</div>
<div class="form-group">
  <label for="inp_reg_mobilefon">Reg mobilefon</label>
  <input type="text" class="form-control" id="inp_reg_mobilefon" name="reg_mobilefon" aria-describedby="inp_reg_mobilefon_help" placeholder="Enter Reg mobilefon">
</div>
<div class="form-group">
  <label for="inp_reg_attendet">Reg attendet</label>
  <input type="text" class="form-control" id="inp_reg_attendet" name="reg_attendet" aria-describedby="inp_reg_attendet_help" placeholder="Enter Reg attendet">
</div>
<div class="form-group">
  <label for="inp_reg_id">Reg</label>
  <input type="number" class="form-control" id="inp_reg_id" name="reg_id" aria-describedby="inp_reg_id_help" placeholder="Enter Reg">
</div>
<div class="form-group">
  <button type="submit" class="btn btn-primary">Save</button>
</div>
<div class="form-group">
  <button type="reset" class="btn">Cancel</button>
</div>
</form>
</div>
</div>
</div>
<script src="bootstrap/4/js/popper.min.js"></script>
<script src="bootstrap/4/js/bootstrap.min.js"></script>
</body>
</html>

— I have recreated forms again and again and I believe these are the relevant files from my latest failure.

The table is mysql – the “reg:id” value is the auto_index and cannot be null

I removed all “can’t be null” requirements from all of the other input types to simplify testing.

There’s some element that I am missing – but working on it by myself has failed over the past day.

Thank you all who can spot the errors!

1 Like

Please check the exact error returned, as explained here:
https://docs.wappler.io/t/debugging-server-connect-errors/2857

Also what exactly do you mean by:

During the day I get a form that seems to work perfectly – then as I try to modify visual layout elements I get null,

What did you modify exactly?

1 Like

AMAAAZING
Debugging showed me that one column couldn’t save the input & that this varchar was only set for 1 character length

The table was supplied to me to use

I upped the length of this database column to 12 characters and
My Form SAVED flawlessly
and my dynamic action to reset form on database connect success worked immediately.

Network XHR and Preview were Green and clean – No errors!

Thank you, Teodor!

This is a debugging lesson that will save me in the future.

I had changed the input value in the form to a string that was longer than 1 character in my tests.

Once Again – Thank You for an important DEBUGGING lesson!

3 Likes