SitePoint Sponsor

User Tag List

Results 1 to 14 of 14

Thread: How to Insert?

  1. #1
    SitePoint Zealot Freelander's Avatar
    Join Date
    Dec 2004
    Location
    Arizona
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How to Insert?

    Hello. I am new to SQL. I am trying to use Microsoft access as MySql.

    INSERT INTO table_name (First Name, Last Name, Phone Number, Email, Gender, Code)
    VALUES (Firstname, Lastname, Phonenumber, Email, Gender, Code )

    I got that code. But what i want it do, is that the user will input the information into the text boxes and then it will input it into MySql database. The textboxes names are Firstname, Lastname, Phonenumber, Email, Gender, Code. So as far as i now this should work. Except where do i insert this. So that it actually does what i tell it to?

  2. #2
    SitePoint Guru MikeBigg's Avatar
    Join Date
    Jun 2004
    Location
    Reading, UK
    Posts
    970
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What server side language are you using?

    All server side languages will have a means of getting the values from the text boxes into a variable. Then you construct a string based on the query you have given.

    Some data intergrity checking should be used so you don't poke rubbish into to your database and that malicious people don't do bad things with your server.

    Mike

  3. #3
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why are you using M$ Access instead of MySQL?
    I have a laptop with 128 MB Ram an a running XP Pro, Apache2, MySQL and PHP quite happily. It makes a wonderful testing environment, occassionaly slows down with a bit of disk thrashing, but much better than using M$ Access (IMHO).

    However, if you really need to use M$ Access, then you need to create a DSN (Data SourceName) in Windoze to access the mdb file - use Control Panel / ODBC to create a DSN. I haven't used M$ Access for several years, so I might be a little out of date with how to create a DSN.

    The you need to use the ODBC functions of PHP to create a connection using that DSN.
    Look at the user notes for [/fphp]odbc_open[/fphp] for further help.

    BTW, you may want to rename your columns so they don't have spaces in their names e.g 'First Name' change to first_name.

  4. #4
    SitePoint Zealot Freelander's Avatar
    Join Date
    Dec 2004
    Location
    Arizona
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well i thought that M$ Access what a type of MySQL? Well then how do i do anything with MySQL? Where would i get a program that i can edit it with?

  5. #5
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There are programs that come with MySQL that allow you to create database, tables and queries.
    Also there is phpMyAdmin - I have never used this, but lots of others say this is a great program - http://www.phpmyadmin.net/home_page.
    Are you using this as a learning tool, or to test your web pages before uploading to a server? If the latter, then I would suggest that you set up your development machine to be simialr to the eventual host machine.

    Hope this helps.

  6. #6
    SitePoint Zealot Freelander's Avatar
    Join Date
    Dec 2004
    Location
    Arizona
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay i downloaded PHPmyAdmin. I want to try it out. But i dont even now where to start with this... What do you use?

  7. #7
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm glutton for punishment, so I generally use text files (I call them .sql files) and the mysql.exe command line program.
    These .sql files contain raw SQL, nicely formatted.
    The reason is that most of my work is done with PHP, so I use the .sql files to create tables and insert some test data, then use the PHP file(s) to manipulate the data as required.
    There is winmysqladmin supplied as part of the MySQL package.

  8. #8
    SitePoint Zealot Freelander's Avatar
    Join Date
    Dec 2004
    Location
    Arizona
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well all i need is to have people input data into a text field, and then have that put into a File of some sort. Which do you think would be the easiest? The data is not to be read by them or anyone else. Its just information for me.

  9. #9
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It all depends on what you want to do with the data.

    If you just want to store it, then writing it to a file will be ok.

    If you want to manipulate the data, perhaps do calculations on it, then store the data in a table. This will give you a way of manpulating tha data via SQL commands.

    Essentially, you want a form that your users fill in. Then, via PHP you can either write a text file or store that data in a database.

    Post some more info on what you want to do, and I'll give you what help I can.

    I have just downloaded phpMyAdmin and installed it. Will have to see how good it is.

  10. #10
    SitePoint Zealot Freelander's Avatar
    Join Date
    Dec 2004
    Location
    Arizona
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay. Thank you. Yes this is what i want to do
    "esentially, you want a form that your users fill in. Then, via PHP you can either write a text file or store that data in a database."

  11. #11
    SitePoint Zealot Freelander's Avatar
    Join Date
    Dec 2004
    Location
    Arizona
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So have you tried out phpMyAdmin? What do you think of it?

  12. #12
    SitePoint Zealot Freelander's Avatar
    Join Date
    Dec 2004
    Location
    Arizona
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Which way would be the easiest way to do this? Would you be able to help me if it were in C#, because i am learning C# in a college course i am taking and so i am planning on programming some games and what not, and i need to be able to read from a database, to check things like, Username and Password and what not.

    Thank you.

  13. #13
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry for not replying earlier.

    I am having problems with my setup at the moment. It is very unstable.

    I can help you with PHP programming, or C or C++. I have not used any of the .NET languages (C#, VB.net etc) as I am not a great M$ fan (as you may have guessed ).

    Certainly, PHP will be able to do everything you want (i.e create HTML pages, read from a database and write to a database). There are built in fucntions that help you do this, for MySQl and other databases.

    I installed phpMyAdmin and had a very quick play before my p.c. went haywire. When it is all fixed, I'll report back on it.

  14. #14
    SitePoint Zealot Freelander's Avatar
    Join Date
    Dec 2004
    Location
    Arizona
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay. Understandable.

    Unfortunatly the two languages you listed "C# and VB.net" Are the languages i now well. They are similiar so once i learned VB.net C# was a snap. From what i have heard though... C/C++ are very similiar to C#...

    Well i was thinking... Maybe i could set it up to where the PHP does all the server connecting and what not. Where C# does everything else... I now others have done it but how would i connect PHP and C#?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •