phpmyadmin won't create a database - mysql

I have never used PHP myAdmin before so I don't know why I am having the troubles that I am. I am trying to create a database, but when I hit "Save" an alert pops up saying, "This is not a number!" and then it won't let me do anything. I am not sure why I am getting this message and I am not sure how to fix it. Here is what I am seeing:
I only need a database with an id, a last name, and a first name. So I am confused on what all to put in some of these other fields. For instance, do I need anything in "Length/Values" or do I need to make "Default" something else? As far as Collation goes I have no idea what to put in there (if I do need to put something in there). I have completely no idea what "Browser transformation" and "Transformation options" are for. We never talked about this. For id I set it to primary so that way no id's will ever be the same. But other than that, I don't know what to do. Any help?

I suppose it wants you to define length values for the VARCHAR fields (names)

Related

MySQL Foreign Key Lookup in Editor

I am flummoxed that no one seems to have ever asked this question, which indicates that the question itself is flawed. But, I don't know how to find out the right question, or answer, other than asking, so here goes:
I'm trying out a couple of tools to connect to MySQL databases and view and edit the data. So far I've tried MySQL Workbench and Database Browser. MySQL Workbench seems to be much more robust and lets you set up foreign keys without having to write any SQL.
The problem, though, is that when inserting and updating data in columns that are foreign keys, I have to manually enter the numeric id of the parent row, and once entered, I have to manually look up which record that number refers to if I want to know. Is there no way to set a display field in the parent table and then be able to choose a value off a dropdown menu when editing the child table? phpMyAdmin does this. I'm perplexed that, not only can't I find a way to achieve this in any non-web-based database tool (I've tried Access before, too), but that no one seems ever to have needed to do it before. Am I completely thinking about this wrong? Do people not use these tools to do this type of work? Is everyone writing their own custom lookup interfaces from scratch in Qbasic? Should I memorize all the ids for my parent rows?
Or are people laughing up their sleeves at this question because it's framed so awkwardly?
SQLYog provides such functionality
https://blog.webyog.com/wp-content/uploads/2011/04/FK-Dropdown1.png

creating my own save command in cakephp

As we all know that cakephp has default save command for inserting record into the database.
But i want to know can i create my own save command in cakephp or modify the existing one.
Can I do this?
You must be asking why i'm asking why i'm saying that? let me give you an live example for this----
Suppose i have an textbox which contains the username entered by the user.I'm not taking this as unique, hence more than one user will insert same username(possible..).
Ex-My name is prakash Gupta and i'm taking the username 'prakash'. There will be other users also whose name can be prakash gupta and they will provide the same username.Now inorder to solve this i'm using random function and attaching some digits behind the username, so that
it will be different for every one.
Now 'save' command will take the username which i entered in the textbox and insert into the database but i want to insert the modified username into the database which i generated
by random function. can this be possible???
if yes let me know....
Normally you don't change the standard one but either add another one or use the beforeSave etc. hooks.
The save functions are part of the Models. Normally you modify them with: Behaviors. See: http://book.cakephp.org/2.0/en/models/behaviors.html They let you modify the models, saving etc. without having to code all directly into your models.
Based on your edit:
Unique constraint
As I see you want a unique username. There are multiple solutions for that. First make sure to set a constraint. Even your random() trick will possibly generate a duplicate since random can create also the same. So username.random(4) could generate multiple times: username1234. You cannot be sure.
Constraints should be set at for example your model level. Start this unique check with validations of CakePHP.
When do you know the username is already used
You will know when the validation failed. So first just validate the record. So before save call model::validate() to check whether your unique constraint is ok. If yes just save.
http://book.cakephp.org/2.0/en/models/data-validation.html
If not you can add your random string and check again. Call model::validate to see if it is now ok. This part could be implemented for example in a behaviour in the beforeSave() method.
Now you have a unique one save your record. Make sure to check whether it succeeded because it is possible that in the meantime another record with that username was added. In that case re-run the process.
Lots of work
It is hard because multiple clients can add data same time in a database before you even know. Most simple is to catch the error, so just call save with your username. If it fails because of your unique constraint add the random() string and try again and again. It should be possible to save. Trick here with your random string because if it is short and a username is used a lot you can run into issues. If your random string is 3 numbers you can have the same username 1000 times, from 000 to 999.
Other option
What you sometimes see is suggestions, the interface suggests some free names based on your username input. You still need the check though.
Another option
Just tell the user it is in use. Maybe add an ajax check so you can instantly show the result by validating the field.

What is 'comments' field in MySQL phpMyAdmin when creating a table?

I have wondered this for many years and every time I did a search it was totally unrelated to what I am looking for as it thought I was searching for "how to comment out data". When you create a new DB table in phpmyadmin, there is a comments field there. What the heck is that for? :) I assumed it allowed you to leave notes on that field or something, but I tried to enter data in that field once and look around that table and didn't see anything. Please let me know what its purpose is. Thank you :)
Its simply just a comment so if you need to go back to that column and remember why/how you created it, you can reference it.
For Example: storeHeadID : int, comment: "This is the ID of the store's head office"
Once you added a comment in the comment field for a column, you should see a dotted underline under that column name in the table's structure view. If you mouse-over that underline you will see your comment as a tooltip. It is very handy to keep track of what the different values in the column mean eg. "status 0:disabled, 1:active, 2:suspended etc."
It's a comment field that describes the column. Although optional, some gui data browser applications format the comment field nicely at the top of the column. I think even good old PhpMyAdmin handles that if I recall correctly. Hope that clears it up for you.
Happy coding.
Your assumption was right, you can describe a column with plain text in any way you want – its purpose, its meaning, its side effects, for later, for others, for user comfort, for completion's sake.
If you're using phpMyAdmin though, take note that this feature was implemented no sooner than in version 2.6.4.
Release notes
Improvements
Display column comments while editing data
In older versions of phpMyAdmin that text (or even the field) doesn't show up at all, even though you can set a comment via inline coding.

Bizarre behavior in MS Access

I have defined three tables, Stores, InventoryItems and StoreItemRecords. My StoreItemRecords table has foreign key columns (StoreID, InventoryItemID) that "point to" the primary keys of the Stores (StoreID) and InventoryItems (InventoryItemID) records. The columns are named the same between the tables.
If I run a query like this:
SELECT StoreID, InventoryItemID FROM StoreItemRecords;
I get some bizarre results. I get:
1, Hammer
2, Box of Nails
3, Some other item name.
So, I am getting the StoreID, as I should. But I am also getting the NAME of the inventory item, not the ID of the inventory item. Also, it is important to note that the InventoryItemID column is defined as a NUMBER, not TEXT.
So somehow, Access is trying to help me by providing the InventoryItemName in place of the InventoryItemID, but I can't seem to find the cause of this behavior or any way to stop it.
[one more note. I have written some VBA code to populate the StoreItemRecords table and, in debug mode, I can "watch" the InventoryItemID values being assigned to the column, and I have verified that the IDs are actually being put in there.]
Has anyone seen behavior like this? I know I am going to feel really dumb when someone points out the goofy thing I am doing to cause this but, at this point, it is worth the embarrassment.
Thanks in advance for any help you can provide.
My money is on one of the fields being setup as a “lookup table” in access. These are generally considered to be a not so useful feature of access trying to help novice developers who find it hard to grasp how a database works.
If you go into the table in design mode you should be able to verify if that is set on the fields in question. If it is turn it off and try the query again
Here is a link on why they are evil
http://www.mvps.org/access/lookupfields.htm

ms access can't edit field because I must delete relationships but there are no relationships to delete

I have built a database on multiple tables. One of these tables has a field (Initials) that was originally defined to have 50 characters. After building the entire thing I realize I would have liked that field to be limited to 3 characters. I tried to change this, but it tells me that I have to delete one or more relationships. So, I open up the relationship window and delete the one relationship that is attached to this field, expecting that I should be able to go back and change the character limit then go back and add the relationship again. So, as of now there are ABSOLUTELY NO relationships touching Initials in the relationships window. I go back to change the char limit and it gives me the same error. I can't even delete Initials and recreate it because of the same error. I went through my entire project and took that field out wherever it appeared. Still, same error. Any ideas?
Per Matt,
apparently when you display a field in a report it does not show up in the relationships >window. I deleted it from the report, edited the char limit, then put it back in the >project. of course, right when i resort to the forum i figure it out. thanks to those who >helped