ID fields in forms

All WYSIWYG Web Builder support issues that are not covered in the forums below.
Forum rules
IMPORTANT NOTE!!

DO YOU HAVE A QUESTION OR PROBLEM AND WANT QUICK HELP?
THEN PLEASE SHARE A "DEMO" PROJECT.



PLEASE READ THE FORUM RULES BEFORE YOU POST:
http://www.wysiwygwebbuilder.com/forum/viewtopic.php?f=12&t=1901

MUST READ:
http://www.wysiwygwebbuilder.com/getting_started.html
WYSIWYG Web Builder FAQ
Post Reply
trevorm
 
 
Posts: 84
Joined: Sat Mar 14, 2020 3:43 pm

ID fields in forms

Post by trevorm »

Hi

I am trying to create a form to add data to an existing Database table. The id field in the existing table is an auto incrementing primary key field. How do set this up in the WYSIWYG Web builder form to ensure that each new record has a new (incremented by 1) value?

Thanks
User avatar
Pablo
 
Posts: 23119
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: ID fields in forms

Post by Pablo »

If you set the database field to 'auto increment' then the database will take care of this.
trevorm
 
 
Posts: 84
Joined: Sat Mar 14, 2020 3:43 pm

Re: ID fields in forms

Post by trevorm »

Further to my inquiry, I am getting the following error

"Failed to insert data into table!
Unknown column 'DATESTAMP' in 'field list'"

displayed when trying to submit the form data to the database.

I do not see a way to ensure the form fields save to the correct DB table fields - the form is not adding to all the fields in the table record.
User avatar
Pablo
 
Posts: 23119
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: ID fields in forms

Post by Pablo »

If you use the built-in form script then the table needs a datestamp field.
The names of the form input fields determine the names of the table fields.

If you need different behavior then you will need to implement your own script.
trevorm
 
 
Posts: 84
Joined: Sat Mar 14, 2020 3:43 pm

Re: ID fields in forms

Post by trevorm »

Hi

Thanks for for your reply Pablo.
What is a datestamp field? or is that just a field with that name to receive data from your built-in script?
User avatar
Pablo
 
Posts: 23119
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: ID fields in forms

Post by Pablo »

The datestamp field stores the date of the form submission.
If you look at the generated PHP code then you can see what the table structure looks like.
trevorm
 
 
Posts: 84
Joined: Sat Mar 14, 2020 3:43 pm

Re: ID fields in forms

Post by trevorm »

Thank you
trevorm
 
 
Posts: 84
Joined: Sat Mar 14, 2020 3:43 pm

Re: ID fields in forms

Post by trevorm »

OK Pablo,

Not being an experienced coder does create some issue for me, some of which you have already helped me with and for that I am grateful.

I am proceeding well with building my web site with WYSIWYG WB and I acknowledge my failure to fully read some of the instructions provided as you pointed out, however comprehensive (or not to a non coder) they may be. But, as I said, not being an experienced coder does have it problems with some elements of the WYZIWYG WB tool.

To return to my query:

As you recommended, I have had a look through the applicable page code, both php and html.

I can see reference in the php code to the "Create Database" and "Create Table" where the Date Stamp, Time and IP fields are referred to but none of my other fields are listed. I can also confirm that via my Service Providers Control Panel, I can see that my database has these fields present in addition to the fields I incorporated when I set up the DB previously for use on an earlier web site.

I can also see in the HTML body section where the inputs and their associated labels are set out. However, I cannot see a comprehensive structure of the table anywhere in the code. That is not to say it is not there, only that I cannot find it.

I am getting the "Failed to insert data into table! Unknown column 'DATESTAMP' in 'field list'" error message even though the DATESTAMP field (and the others) are present in the table.

As I have said several times, I am grateful for your help but I would appreciate a little more "lower level" guidance with this and other issues bearing in mind my coding level and the pretext on which WYSIWYG WB is sold.

I do believe this tool is exceptional but here are some aspects where guidance notes are a slanted towards experienced coders.

I would just like to say I can see where WYSIWYG WB will speed up the UI development for experienced coders. However, I would have thought it unlikely that experienced coders would need this tool to develop a complete web site. That said, I am sure it is obvious to you when reviewing my questions, that I am not an experienced coder hence why I am using this impressive tool to build a web site for my daughter's company. This product is sold with the fore-runner that you do not need to know any code and hence why it is appealing to me. Therefore I do need straightforward guidance on this matter. Thanks.
User avatar
Pablo
 
Posts: 23119
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: ID fields in forms

Post by Pablo »

The error is generated by the server.
So, either your settings are not correct or there is something wrong on the server side.
I suspect that the configured table is not correct.

before you begin, make sure the specified table does not exists. Then you can be sure the correct table structure will be generated by the script.
Else you will have to update the structure in the table yourself. This requires some MySQL knowledge.
trevorm
 
 
Posts: 84
Joined: Sat Mar 14, 2020 3:43 pm

Re: ID fields in forms

Post by trevorm »

Hi Pablo,
Unfortunately the table does exist and has data in it, as it is a table that has been and still is in use by another web site which is to be replaced by this new site.

Your MySQL CRUD extension works fine and I can edit and add records with no problem with the CRUD. However, I don’t want users to have the hat much access to the database for obvious reasons hence that is by I am using a form.
User avatar
Pablo
 
Posts: 23119
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: ID fields in forms

Post by Pablo »

For the form script to work, the data structure must be correct. It must match the fields in the form.
The built-in script cannot update the structure of existing tables because this could affect the data.
So, either create a new table or update the structure of the table manually.
MGD4me
 
 
Posts: 276
Joined: Tue May 02, 2017 11:56 pm
Location: British Columbia, Canada

Re: ID fields in forms

Post by MGD4me »

the table does exist and has data in it, as it is a table that has been and still is in use by another web site
If you you are using an existing database and table, then the form on the new website must use the same identical fields and structure. Can you confirm the new structure matches exactly?
trevorm
 
 
Posts: 84
Joined: Sat Mar 14, 2020 3:43 pm

Re: ID fields in forms

Post by trevorm »

Hi Pablo,

The good news is that I have created a new (different) table by setting the table name jn the form as one that does not exist in the database. to test it and that works. I let the system create the table. Therefore as you say is a structure issue.

I had missed some fields off the form intentionally because I didn't need them. If I recall correctly, on your MySQL CRUD Extension, I could list the fields and select which ones I wanted to display on the web site - i.e. I did not have to list all the fields on the actual form. I assumed that as there is no such facility on this form, I could just list the fields I want to use - alas not. This is not consistent with the CRUD which I believe you also designed?

As I said, on the original table I opened this discussion on, the code produced to create the page does not, as far as I can see list all the fields in the structure. It only lists the Date Stamp, Time and IP fields. However, I know I have not included all the fields in the form for the reason I say above. Therefore the structure of the form is not the same as the table.

It would be much better if there was a consistent approach to forms across WYSIWYG WB with respect to how they are set up in relation to the database table.

I have no idea how to alter the structure of the existing table (which as data in it), which I would prefer to use.
trevorm
 
 
Posts: 84
Joined: Sat Mar 14, 2020 3:43 pm

Re: ID fields in forms

Post by trevorm »

I forgot to say the fields I don't want to use in the existing table do NOT have any data in them
User avatar
Pablo
 
Posts: 23119
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: ID fields in forms

Post by Pablo »

The built-in script is a generic solution. The script is generated based on the input fields of the form.
If you need different functionality then you will need to implement a customer script.
MGD4me
 
 
Posts: 276
Joined: Tue May 02, 2017 11:56 pm
Location: British Columbia, Canada

Re: ID fields in forms

Post by MGD4me »

Perhaps Pablo can add his design knowledge here, as I don't have an inside look into what actually takes place during attempts to access the database.

But, as you have already noted, if there is no initial table, the script will create one with the required fields, and with a particular structure. That is to say, each field is defined as being text, an integer, a date field, and so on, plus the field width.

On the second access attempt, the table obviously now exists, so the script can now read and write to the table as expected. But I don't know if the script examines the table to match the fields AND structure, or simply the structure of the fields required for your new form. You can see I am grasping at straws here, but the script obviously can determine something doesn't line up.

In the meantime, you can use phpMyAdmin to examine the structure of the existing and new tables, and compare the two. That would provided some definite clues as to what, or how you might be able to tweak the table, but no guarantees of course. Sorry...

Good luck.
WWBman
 
 
Posts: 904
Joined: Fri Jan 08, 2010 6:10 pm

Re: ID fields in forms

Post by WWBman »

Just a thought.
Have you looked at the MySQL Connect extension?
You can create the form to use only the DB fields you want.
No need to change the structure of the DB.
trevorm
 
 
Posts: 84
Joined: Sat Mar 14, 2020 3:43 pm

Re: ID fields in forms

Post by trevorm »

Hello,

Thanks for your input you guys - I really appreciate it.

I have had a look at MySQL Connector - Version 1.2. which I already have installed but it would appear from what I have read in the instructions that you cannot create a new record with it, you can only edit existing records. Am I understanding this correctly?

Looking at MySQL CRUD extension, which I also have installed, does allow you to add new records but also allows editing of existing records which is far to to dangerous for my people. I don't know if this can be used to only set up an new record form, leaving out the edit, review, etc???

Thanks again for your input.
WWBman
 
 
Posts: 904
Joined: Fri Jan 08, 2010 6:10 pm

Re: ID fields in forms

Post by WWBman »

You create new records by using mySqlNew and then mySqlSave.
From the Help:
mySqlNew()
clears the form to add a new record.
The data will not be saved until you call mySqlSave().
trevorm
 
 
Posts: 84
Joined: Sat Mar 14, 2020 3:43 pm

Re: ID fields in forms

Post by trevorm »

Yes, I revisited the instructions of MySQL Connector - Version 1.2 after my last post and noted the options in the instructions, item 6. I will give this a try.

Could be getting somewhere now.

Thanks everyone.
Post Reply