Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jun 2012
    Posts
    26
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Help! textarea value doesnt insert into msql database

    With thanks to all coders here who have contributed and made the forum a success..

    I am stuck with, may be a very basic problem.
    I have an html form with some input fields.
    I've tried the following:

    msql part
    Code:
    -- database connection information --
    mysql_query("INSERT INTO `article` (user, desc) VALUES('{$posts['name']}', '{$posts['desc']}')");
    echo "added successfully!";
    And the form part
    1.
    Code:
    <form method="post">
    <input name="name" value="<?php if(isset($posts["name"])) { echo $posts["name"];}?>"/>
    <input name="desc" value="<?php if(isset($posts["desc"])) { echo $posts["desc"];}?>"/>
    * This works fine but..

    2.
    Code:
    <form method="post">
    <input name="name" value="<?php if(isset($posts["name"])) { echo $posts["name"];}?>"/>
    <textarea rows="10" name="desc" value="<?php if(isset($posts["desc"])) { echo $posts["desc"];}?>"/>
    * This doesnt insert the value into msql database.


    The only difference between 1 and 2 is, 1 has input name="desc" and 2 has textarea name="desc"

    How can I solve this?

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    You didn't do any error checking in your php code. If you did you would see the problem is with your database INSERT statement. DESC is a reserved word so you need to use another name for the column name in the table.

  • Users who have thanked guelphdad for this post:

    sanomani (09-27-2012)

  • #3
    New Coder
    Join Date
    Jun 2012
    Posts
    26
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by guelphdad View Post
    You didn't do any error checking in your php code. If you did you would see the problem is with your database INSERT statement. DESC is a reserved word so you need to use another name for the column name in the table.
    I am new to coding.. dont know about reserved words. following your instructions now..

  • #4
    New Coder
    Join Date
    Jun 2012
    Posts
    26
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Awesome!

    Lots of thanks. You solved the problem.

  • #5
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    Quote Originally Posted by sanomani View Post
    I am new to coding.. dont know about reserved words.
    the current list
    http://dev.mysql.com/doc/refman/5.6/...ved-words.html


  •  

    Posting Permissions

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