Reply
new to mysql, sql and php
Old 08-09-2006, 07:11 PM new to mysql, sql and php
jason_bristol's Avatar
Ultra Talker

Posts: 254
Name: Jason Eyermann
Location: england bristol
I've only been learning these for about 3 weeks now. So far I have created a data base in Cpanel on my remote server. I have opened a php page in dreamweaver and managed to get connected to the data base. I want to create a few test tables. I see there is an option in Cpanel to create the tables. I created a test table called city with 4 rows. A page has come up that I did'nt expect. At the top of the table are a long list of fields going across. these are - Field, type, length/values, collation, attributes, null, default2, Extra, (for small images), comments. could someone please either tell me what they mean or tell me of a good site that provide tutorials for this.
There are also instuction on uploading a .sql file into the database. Does anyone know how I would compile this on a mac.

Also when I create my Database in Cpanel I was given some code to use with php pages. But where does it go. The code is -

PHP Code:
$dbh=mysql_connect ("localhost""aspir3_jasonUser""<PASSWORD HERE>") or die ('I cannot connect to the database because: ' mysql_error());
mysql_select_db ("aspir3_jasonDatabase"); 
thanks
__________________
My Site/Blog - AspireCreate.com

Last edited by jason_bristol : 08-09-2006 at 08:20 PM.
jason_bristol is offline
Reply With Quote
View Public Profile Visit jason_bristol's homepage!
 
When You Register, These Ads Go Away!
Old 08-10-2006, 11:38 PM Re: new to mysql, sql and php
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
Converting Video For YouTube
Posts: 2,337
Name: Keith Marshall
Location: West Hartford, CT
It seems like your going through phpMyAdmin which is a handy tool for interfacing MySQL. I'll explain briefly of what each type is:

Field: This is the field name of your selected table
Type: This sets the type of data to be stored in this column. For standard text, you want VARCHAR, and for an id number, you want INT
Length/Values: This sets the maximum number of Alpha / Numeric charactures to allow (VARCHAR cannot hold more than 255 chars)
Collation: You can leave this set to the default, or change to utf-8
Attributes: Chances are you wont need this until you get more advanced
Null: Null will allow the field to be empty upon insert, Not null will require a value
Default: This gives the default value to a field that is not null and that does not pass data upon insertion (example the default value for varchar column for a name field could be 'Not Available')
Extra: Set to auto increment if its the primary id field
Index (the four small images): You can leave set to default except for the primary key index (the field that is supposed to be the id)
Everything else: You can leave set to default

Do a Google search for PHP MySQL Tutorials to find some good info on how to make it all work together. Thats how I learned. Good luck!
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 08-10-2006, 11:46 PM Re: new to mysql, sql and php
jason_bristol's Avatar
Ultra Talker

Posts: 254
Name: Jason Eyermann
Location: england bristol
That is brilliant! thanks mgraphic. yes I am going through phpmyadmin. I am going through a tutorial for both mysql and php at the moment which i started today. The only other thing I can't seem to find out is what is that code above for. I'm not sure that I need it because I don't create my databases through php.

thanks
jaosn

ps. anyone else wanting to learn. The best tutorials That i have found is on a site called http://www.tizag.com Really eazy to follow tutorial.
__________________
My Site/Blog - AspireCreate.com
jason_bristol is offline
Reply With Quote
View Public Profile Visit jason_bristol's homepage!
 
Old 08-10-2006, 11:51 PM Re: new to mysql, sql and php
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
Converting Video For YouTube
Posts: 2,337
Name: Keith Marshall
Location: West Hartford, CT
In the code sample above, you will need that to connect to the MySQL database before you can start making queries to it.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 08-11-2006, 08:56 AM Re: new to mysql, sql and php
jason_bristol's Avatar
Ultra Talker

Posts: 254
Name: Jason Eyermann
Location: england bristol
One last question if I can. Does this code go at the top head or body.

thanks
__________________
My Site/Blog - AspireCreate.com
jason_bristol is offline
Reply With Quote
View Public Profile Visit jason_bristol's homepage!
 
Old 08-16-2006, 04:56 PM Re: new to mysql, sql and php
yoemanspiffy's Avatar
Experienced Talker

Posts: 42
Did you get this sussed out bud?

The code you list is for:
Line 1: connecting to the SERVER
Line 2: connecting to the DATABASE

Alll your Database goodies need to be bewteen those two lines of code and the line: mysql_close($dbh);

For example: if you were going to do a query on a table emails to bring up a list of emails, some code that might fit inside those lines might look like this:
PHP Code:
$select "SELECT * FROM emails;";
 
$result mysql_query($select);
while (
$row mysql_fetch_array($result,MYSQL_ASSOC)) 
{
print 
"emailID:".$row{'emailID'}." emailAddress:".$row{'emailAddress'}." emailEntryDate: ".$row{'emailEntryDate'}."<br>";

What you have there is just the start of the DB connection.
__________________
My grandfather used to work for your grandfather. Of course the rates have gone up.

http://www.goldentechinc.com

Last edited by yoemanspiffy : 08-16-2006 at 05:08 PM.
yoemanspiffy is offline
Reply With Quote
View Public Profile Visit yoemanspiffy's homepage!
 
Reply     « Reply to new to mysql, sql and php
 

Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13726 seconds with 12 queries