Page 1 of 1
Error with Autoincrement?
Posted: Tue Apr 13, 2021 11:44 pm
by orangezero
I've made about six fast forms just now. Four of them seem to work fine, while two give errors when I attempt to input data and save. It gives a long list of yellow print, but the important part I believe is copied below. I do not have a subform, by the way, but in both cases it gives that error. I believe it has something to do with the auto increment feature of the nuNumber, based on line 122 of nudatabase.php, but I believe all six fast form had an auto increment.
"Warning: Attempt to read property "Extra" on bool in C:\xampp\htdocs\nuBuilder45\core\nudatabase.php on line 122"
and then at the end in bold:
:["testtest<\/b> is not a valid table name for a Subform"],"log_again":null,"global_access":"1","data_mode":null,"is_demo":false,"remember_me_2fa":false,"token_validity_time_2fa":168,"form_access":"0","javascript":null,"target":null,"buttons":{"Add":"1","Print":"1","Save":"1","Clone":"1","Delete":"1","Run":"","RunHidden":""},"run_code":"","run_description":""}
I'm sure this is an easy fix, but I can't seem to figure out what I'm doing wrong. Thanks
Re: Error with Autoincrement?
Posted: Wed Apr 14, 2021 12:14 am
by kev1n
Hi,
I'm able to replicate that when entering an invalid Primary Key. Make sure it's written correctly and it's case sensitive.
Re: Error with Autoincrement?
Posted: Wed Apr 14, 2021 9:04 pm
by orangezero
Ok, I also noticed it didn’t seem to create the two tables but did make the form. I’m not exactly sure how to proceed. Should it be possible to simply create the tables in myphpadmin, and then successfully link to the forms in nubuilder? Or is that a lot of work and it would be easier to remake the fast form after deleting the form (a pain, but I don’t have enough experience to know which is less work).
It appears I don’t understand how fast forms creates the primary key. Is it auto generated such that if my table name is “test” then the primary key is created and set as “test_id?” I think I was adding my own and wanting the primary key to be a unique auto generated number. Am I just duplicating some work? Or do I need a auto number for something like an invoice?
Re: Error with Autoincrement?
Posted: Wed Apr 14, 2021 9:16 pm
by kev1n
orangezero wrote: Should it be possible to simply create the tables in myphpadmin, and then successfully link to the forms in nubuilder? Or is that a lot of work and it would be easier to remake the fast form after deleting the form (a pain, but I don’t have enough experience to know which is less work).
Yes, you can create the table with phpMyAdmin. If the table is named the same as the one created with Fast Forms, nothing else needs to be done.
orangezero wrote:
It appears I don’t understand how fast forms creates the primary key. Is it auto generated such that if my table name is “test” then the primary key is created and set as “test_id?” I think I was adding my own and wanting the primary key to be a unique auto generated number.
Fast Forms create the PK for you and it must also not be entered while creating the form, otherwise the table will not be created (this is a bug which will be fixed).
orangezero wrote: Or do I need a auto number for something like an invoice?
That would be an example of application.
Re: Error with Autoincrement?
Posted: Thu Apr 15, 2021 9:14 pm
by orangezero
I think I asked the question in a silly way. I meant to ask if it is a standard practice for something like an invoice to have both a primary key and an autogenerated number? I would guess maybe on something like an invoice it may nice for bookkeeping to have "invoice #s" separate from the primary key, but for lots of other situations the autogenerated primary key is sufficient for the database to function?
In any case, I'm not sure why, but I can successfully make a three or four fields of varchar or int without issue on a fast form. I still have a problem when I do 20-25 fields and some are autodates, varchar, and maybe a note field. Even if I leave out the nunumber field.. It unfortunately seems to be more common after writing a lot of info in... Is any of this part of the bug you mentioned? Or should all that work and I just misnamed something somewhere? I believe the main issue was some items needing to be lowercased, no spaces, etc.
I got one table fixed and it shows in phpmyadmin and also saves. Perfect. The other fast form table I (re)created in phpmyadmin and it eliminated the yellow error screen. And then in nuBuilder it looks like it saves but on the browse screen (and phpmyadmin) it doesn't actually save it. My assumption is I have one or two fields named incorrectly, maybe best to start that table over completely.
Also, if done correctly, it does appear the table and fields should show up in phpmyadmin almost instantly, or at least after a refresh. This does help to find the issue sooner.
Many thanks.
Re: Error with Autoincrement?
Posted: Thu Apr 15, 2021 9:23 pm
by kev1n
orangezero wrote: would guess maybe on something like an invoice it may nice for bookkeeping to have "invoice #s" separate from the primary key
Absolutely, you can use an auto number in addition to the primary key.
orangezero wrote:, but for lots of other situations the autogenerated primary key is sufficient for the database to function?
Yes, indeed.
orangezero wrote:
Is any of this part of the bug you mentioned? Or should all that work and I just misnamed something somewhere? I believe the main issue was some items needing to be lowercased, no spaces, etc.
That should actually work fine, even if the field names are not lowercased or contain spaces