DMXzone Database Updater PHP Support Product Page

Solved

Insert Record With Server Connect

Reported 23 Mar 2016 16:07:12
1
has this problem
23 Mar 2016 16:07:12 Keith Mears posted:
Hi - As with the delete server action I am struggling to get the Insert Record to work following the tutorial with the Server Connect Module. Tried a number of times but it just refuses to run the executor.

Have reverted back to the old method for now as that still works fine for me, Can you give me any idea how long the new tutorials are likely to be?

Regards

Keith

Replies

Replied 23 Mar 2016 16:26:04
23 Mar 2016 16:26:04 Teodor Kuduschiev replied:
Hello Keith,
the insert record tutorial has been updated today. We continue updating them tomorrow. Please check the new video here: www.dmxzone.com/go/23303/insert-records-into-a-database/
Replied 25 Mar 2016 00:26:42
25 Mar 2016 00:26:42 User  replied:
I can't get the form submit to work at all. There is no response to clicking the submit button after following this or previous tutorials. Does the behavior to clicking a submit button need to be defined or is the submit button already defined?
Replied 25 Mar 2016 08:05:00
25 Mar 2016 08:05:00 Teodor Kuduschiev replied:
Hello,
If you have selected "Auto run on: Form Submit" and attached your form to the action executor, there is nothing more needed.
Please check this video, and tell me if you see any error: www.dmxzone.com/go/32354/debugging-problems-in-dmxzone-server-connect/
Replied 25 Mar 2016 09:49:07
25 Mar 2016 09:49:07 Keith Mears replied:
Hi Teodor

Thanks, yes have used the new tutorial and all seems to work fine. Is the Data Bindings panel missing, I cannot format the data being inserted as before in the Data Base Updater and cannot find this feature in the new server connect. This was a valuable feature with the Data Base Updater.

Regards

Keith
Replied 25 Mar 2016 09:56:55
25 Mar 2016 09:56:55 Teodor Kuduschiev replied:
Formatting data, when posting it to the server will be available with the release of the Server Formatter extension.
What would you like to format - there might be a solution, until we release it?
Replied 25 Mar 2016 22:45:01
25 Mar 2016 22:45:01 User  replied:
For the life of me I can't get this to work. I think I followed the tutorial exactly. The submit redirects to the output page but no new record added. Any adjustment to the setup and the whole thing falls apart.

I must be doing something wrong but no idea..

I'm working Mac.
Replied 25 Mar 2016 23:10:24
25 Mar 2016 23:10:24 User  replied:
Disregard; now got it going.
Replied 20 May 2017 18:45:02
20 May 2017 18:45:02 Raymond Wiggins replied:
Not sure how "user" fixed it. I have also followed the videos, my form submits and the Executor "onSuccess" displays a message (I setup with a Popup message). Yet, no data is entered into my database.

I checked my PHP version 5.3.5 (tried changing my PHP to 5.5 as well)
PDO is enabled.
This is on my live server where it's not working on insert. I tried on my local computer (WampDeveloper PHP 5.6.3) - but I couldn't get past a database connection issue "invalid data source name" - even though I quadruple checked all my settings. But I'm more concerned about the live server issue of insert not working.



<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Test Insert Document</title>
<script type="text/javascript" src="ScriptLibrary/jquery-latest.pack.js"></script>
<script type="text/javascript" src="ScriptLibrary/dmxDataBindings.js"></script>
<script type="text/javascript" src="ScriptLibrary/dmxDataSet.js"></script>
<script type="text/javascript" src="ScriptLibrary/dmxServerAction.js"></script>
<script type="text/javascript">
function MM_popupMsg(msg) { //v1.0
  alert(msg);
}
</script>
</head>

<body>
<form role="form" id="regForm" class="text-center" method="post">
               country number <input type="text" class="form-control" id="regLuckyNumber" name="regLuckyNumber" placeholder="">
                <input type="submit">
</form>
<?php phpinfo(); ?>

<script type="text/javascript">
/* dmxServerAction name "myTestExecute" */
       jQuery.dmxServerAction(
         {"id": "myTestExecute", "url": "dmxConnect/api/insert.php", "form": "#regForm", "data": {}, "onComplete": "MM_popupMsg('Success');", "onSuccess": "MM_popupMsg('On Success');", "onError": "MM_popupMsg('On Error');"}
       );
  /* END dmxServerAction name "myTestExecute" */
</script>
</body>
</html>




The file in dmxConnect/api/myInsertTest has the following:


<?php
require('../../dmxConnectLib/dmxConnect.php');
$app = new \lib\App();
$app->define(<<<'JSON'
{
  "exec": {}
}
JSON
);
?>



not sure if there should be more in this file (I defined the table & post data relationship in the Database Insert named "myInsertTest"

Running Dreamweaver CC2017.1 Build 9583

I'm running out of ideas - seems like such a simple task.
Replied 21 May 2017 09:54:46
21 May 2017 09:54:46 Teodor Kuduschiev replied:
Hi Raymond,
I see that you run an action called: dmxConnect/api/insert.php
While you say that

QuoteI defined the table & post data relationship in the Database Insert named "myInsertTest"


Please make sure you are running the right server action within the action executor.
Replied 22 May 2017 18:56:00
22 May 2017 18:56:00 Raymond Wiggins replied:
1. I start with a file below

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Test</title>
</head>

<body>
<form role="form" id="myForm" class="text-center" method="post">
country number <input type="text" class="form-control" id="myIDFormInput" name="myIDFormInput" placeholder="">
<input type="submit">
</form>
</body>
</html>


2. Then, in DMXZone Server Connect Window I "Add New" and name it "MyDebugTest".

3. Then select "Globals" in Action Steps I navigate to the page with the form in Linked Page and select the form name. Then click "Import From Form".

4. In Globals, I can see that $_POST populates with the appropriate fields.

5. I right-click on Execute->Steps and choose "Add Database Connection", then click the "Connection Options"

6. In the Database Connection popup, I name the connection "MyDebugConnection" then fill out the MySQL properties. In this case, I use the url instead of "localhost" to prevent any confusion with my local server - though I've tried both ways.

I test the connection and receive message "Database Connection OK!". I click "Apply" then "OK". I notice that the Name in the Connection Properties area doesn't match what I just created, so I click the folder icon and navigate to the new connection "MyDebugConnection".

7. I right-click on Execute->Steps->Database Connection: MyDebugConnection and choose "Add Database Insert" and name it "MyDebugInsert".

8. I open "Insert Options", select the appropriate table and click the + icon to load the table fields. I select the fields and press the arrow icon to move them to the Columns tab. For each field in the columns tab I adjust the value using the Server Data Bindings and the $_POST values in the Global area. click Apply then OK.

9. I now move to the Data Bindings Window, select "Server Connect Action Executors" and click the + "Add New Data Source".

10. The Define Server Action Executor pops up. I name it "MyDebugExecutor", choose "Form Submit", choose "MyDebugTest" in Server Action, I bind to my form and change send method to POST. I click "Options", then "Behaviors". Select "onSuccess" then Popup Message and assign a message. I do the same for "onError". Then click "OK".

11. The source code for my file looks like


<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Test</title>
<script type="text/javascript" src="ScriptLibrary/jquery-latest.pack.js"></script>
<script type="text/javascript" src="ScriptLibrary/dmxDataBindings.js"></script>
<script type="text/javascript" src="ScriptLibrary/dmxDataSet.js"></script>
<script type="text/javascript" src="ScriptLibrary/dmxServerAction.js"></script>
<script type="text/javascript">
function MM_popupMsg(msg) { //v1.0
  alert(msg);
}
</script>
</head>

<body>
<form role="form" id="myForm" class="text-center" method="post">
country number <input type="text" class="form-control" id="myIDFormInput" name="myIDFormInput" placeholder="">
<input type="submit">
</form>
<script type="text/javascript">
/* dmxServerAction name "MyDebugExecutor" */
       jQuery.dmxServerAction(
         {"id": "MyDebugExecutor", "url": "dmxConnect/api/MyDebugTest.php", "form": "#myForm", "data": {}, "onSuccess": "MM_popupMsg('Success.');", "onError": "MM_popupMsg('Error');"}
       );
  /* END dmxServerAction name "MyDebugExecutor" */
</script>
</body>
</html>


12. Just to be sure, I "put" the entire site. Then test in browser.
13. I fill out the form, submit, get the "Success" message. But the database shows no new entry.


--

PHP Version 5.3.5
MySQL/MySQLi 5.1.54

Folder "dmxDatabaseSources" is empty on both the server and my local drive.

On server the folder structure for the ScriptLibrary folder has
/dmxDatabaseConnector
//adapters
///MySQL
////sqlBuilder.php
//dmxDataBindings.js
//dmxDataSet.js
//dmxServerAction.js
//jquery-latest.pack.js

dmxConnections folder has the file MyDebugConnection.php (as well as some other test files)
dmxConnect/api folder has the file MyDebugTest.php (as well as some other test files)

dmxAppConnect has
/dmxDataTraversal
//dmxDataTraversal.js
/config.js
/dmxAppConnect.js

dmxConnectLib has four folders and App.php (folders have numerous folders/files within them)

I use phpMyAdmin to view the results, but I have also written a basic SQL query and get the same result. I am able to add to the database using a standard mysqli_connect "INSERT INTO" (all the needed code) and that works perfectly.

Not sure why the system would report success, if there wasn't success. Seems like I followed the instructions correctly.







Replied 23 May 2017 11:06:59
23 May 2017 11:06:59 Teodor Kuduschiev replied:
Hello Raymond,
Please provide a link to your page where we can check what's wrong.
This reply was removed on 12/5/2021 12:49:03 PM.
See the changelog

Reply to this topic