Advanced Search

Results 1 to 10 of 10

Thread: Insert data into My Sql

  1. #1
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default Insert data into My Sql

    Hi.

    How do I insert info from a textbox to a text file on my MySql database?

    I know how to connect to my database using PHP, so all I need now is to be able to add data to it, then retrieve it on the following page.

    Here's what I'm trying to do:
    A page where user's can put their name and message, and it pops out on the other page. Basically like a comments page.
    - Mike

  2. #2
    Join Date
    Jun 2006
    Posts
    182
    Thanks
    0
    Thanked 14 Times in 14 Posts

    Default

    Quote Originally Posted by mburt
    How do I insert info from a textbox to a text file on my MySql database?
    To a text file on your MySQL database???
    Perhaps you mean just into the database? Use mysql_query function (see php.net).

  3. #3
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Yes, sorry I just meant into the database
    - Mike

  4. #4
    Join Date
    Jun 2006
    Posts
    182
    Thanks
    0
    Thanked 14 Times in 14 Posts

    Default

    Just check out the mysql_query function on php.net and you may also want to read that.

  5. #5
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Err... I don't know what to look for. Could you help me?
    - Mike

  6. #6
    Join Date
    Jun 2006
    Posts
    182
    Thanks
    0
    Thanked 14 Times in 14 Posts

    Default

    Look at the samples: http://php.net/mysql_query

    PHP Code:
    <?php
    /* Connecting, selecting database
    $link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
       or die('Could not connect: ' . mysql_error());
    echo 'Connected successfully';
    mysql_select_db('my_database') or die('Could not select database');
    */

    // !!! Performing SQL query, that's how you GET the data OUT of the database. !!!
    $query 'SELECT * FROM my_table';
    $result mysql_query($query) or die('Query failed: ' mysql_error());

    // Printing results in HTML
    echo "<table>\n";
    while (
    $line mysql_fetch_array($resultMYSQL_ASSOC)) {
       echo 
    "\t<tr>\n";
       foreach (
    $line as $col_value) {
           echo 
    "\t\t<td>$col_value</td>\n";
       }
       echo 
    "\t</tr>\n";
    }
    echo 
    "</table>\n";

    /* Free resultset
    mysql_free_result($result);

    // Closing connection
    mysql_close($link);
    */
    ?>

  7. #7
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    To access a database you need to understand SQL. Here is a good SQL tutorial.

  8. #8
    Join Date
    Jul 2006
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by blm126
    To access a database you need to understand SQL. Here is a good SQL tutorial.
    Link doesn't works:
    http://www.freewebmasterhelp.com/tutorials/phpmysql

  9. #9
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Oh crap... That page must have been taken down recently. I had used that link and found it quite handy. I have to look for another one I guess.
    - Mike

  10. #10
    Join Date
    Sep 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Hello,

    Please try to use this link may be it will help

    http://www.eukhost.com/support/phpmyadmin.php

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
  •