Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-06-2009, 04:01 AM   PM User | #1
witch_wyzwurd
New Coder

 
Join Date: Apr 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
witch_wyzwurd is an unknown quantity at this point
Where Do I Place Initial php mySQL Code?

I'm a little lost on something.

I know I can create a database using cpanel's mySQL manager and create and edit a table with myphpadmin, but I want to learn how to program the actual code first...

I've gone through tutorials on php mySQL, and I grasp the language, but I'm failing to read anywhere that answers my following questions...

Where do I put the code for an SQL database and Table and its columns of data for my web site? Do I put the code in its own file and save it as .php? If so, how is the code enacted to actually create the database, table, columns, etc.? Do I include the code in my index page? Is it only supposed to load one time, since the database is created only once? I don't get this aspect of it.
witch_wyzwurd is offline   Reply With Quote
Old 04-06-2009, 07:34 AM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,687
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
Well, there's a "manual" way to do it, from a command prompt. Of course, this way pretty much sucks monkey butt, so the way I suggest is you use phpMyAdmin to create the tables as you want them, then do an "Export", structure only, and save that to a file. Now, your entire schema can be recreated in seconds-- just import that file (also using phpMyAdmin) and presto, your database is created.

I don't know why you want to mess around with using PHP to create your database, since, as you say, this is something you'll only do once. You certainly wouldn't bother putting create table queries in your index.php file.
__________________
Fumigator is offline   Reply With Quote
Old 04-06-2009, 12:55 PM   PM User | #3
witch_wyzwurd
New Coder

 
Join Date: Apr 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
witch_wyzwurd is an unknown quantity at this point
Hmmm. Why does the command prompt way suck monkey butt?

I started creating a table in myphpadmin. I didn't totally complete it, so at the bottom of the screen where there's a SAVE button next to "Or Add [number] Field(s), I pushed the SAVE button, but because all of the fields are not filled in, I can't save it. Is there a way to SAVE a partially filled out Table in myphpadmin, to come back to it later?

This is why I want to hand-code everything. These WYSIWYG type programs always fail me. Is the command-prompt way all that hard?
witch_wyzwurd is offline   Reply With Quote
Old 04-06-2009, 04:22 PM   PM User | #4
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,687
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
Not "hard", per se, but just more manual. I have no idea why you'd not be able to save your table-- what's the error? You can, incidentally, execute any SQL query (CREATE TABLE being just like any other SQL query) so if you want to write your CREATE TABLE statement by hand, you can still execute it through phpMyAdmin.

You can do the same thing at the command prompt, so if you're more comfortable doing that, feel free.
__________________
Fumigator is offline   Reply With Quote
Old 04-06-2009, 11:17 PM   PM User | #5
witch_wyzwurd
New Coder

 
Join Date: Apr 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
witch_wyzwurd is an unknown quantity at this point
Ok. I see now where Ican click a "query" icon to pull up a box to write SQL code. I didn't see that option at first. That'll do just fine for programming area.

But...

After creating a table and selecting how many fields I want, a table shows with a bunch of empty fields. Now if I decide to not fill in a field or any field and press the SAVE-button at the bottom of the screen, I get an alert pop-up box that says: "Missing value in the form!" If I fill in just one value, or some values and leave blanks, I get the same message.

Which is why I'm assuming I have to complete the whole table in order to save it, which sucks monkey butt!

Also, when I look in the left column, where the "query" icon is, it says "No tables found in database." I'm guessing that is so because I haven't been able to save the table yet? At the top of the screen, it states the Table name though.

P.s. I just tried something. I created one field and plugged in some values to satisfy a full column being complete. It saved. Is that normal? Should I have to complete the table one field by one field? Or have to create a whole column before it's allowed to be saved?

Last edited by witch_wyzwurd; 04-06-2009 at 11:24 PM..
witch_wyzwurd is offline   Reply With Quote
Old 04-07-2009, 02:01 PM   PM User | #6
djm0219
Senior Coder

 
djm0219's Avatar
 
Join Date: Aug 2003
Location: Wake Forest, North Carolina
Posts: 1,229
Thanks: 2
Thanked 190 Times in 188 Posts
djm0219 is on a distinguished road
When you create a new table using phpMyAdmin and provide it with a column count it expects you to supply all of the column details at that time. It can show you the name of the table you will be creating because you've already supplied it but it won't complete the table unless you also supply all of the column definitions for the number of columns you asked for.

You may certainly create columns one at a time but it will likely be a bit tedious. phpMyAdmin makes the assumption that when you create a table with x number of columns you already know how you want those columns defined and expects all of the details before it will actually create the table.
__________________
Dave .... HostMonster for all of your hosting needs
djm0219 is offline   Reply With Quote
Old 04-07-2009, 03:15 PM   PM User | #7
witch_wyzwurd
New Coder

 
Join Date: Apr 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
witch_wyzwurd is an unknown quantity at this point
Ok. I'm getting somewhere now. I have some more questions in mind, but I'll take these initials steps first and try to answer them myself as I plug along. Thanks.
witch_wyzwurd is offline   Reply With Quote
Old 02-19-2012, 06:45 PM   PM User | #8
sucaritas
New to the CF scene

 
Join Date: Feb 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
sucaritas is an unknown quantity at this point
hi all i disliked phpMyAdmin's interface so i decided i would built a new MySQL manager like the MySQL query browser. please if you have a change can you give it a try
github ->https://github.com/sucaritas/MyXQuery
LIVE DEMO -> http://www.farfile.com/Demos/MyXQuery/
it works like the MySQL query Browser (ctrl+enter to execute a query)
you can right click on the tree for other things too.
sucaritas is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:24 AM.


Advertisement
Log in to turn off these ads.