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 09-27-2012, 06:38 PM   PM User | #1
sanomani
New Coder

 
Join Date: Jun 2012
Posts: 26
Thanks: 9
Thanked 0 Times in 0 Posts
sanomani is an unknown quantity at this point
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?
sanomani is offline   Reply With Quote
Old 09-27-2012, 07:13 PM   PM User | #2
guelphdad
Super Moderator


 
guelphdad's Avatar
 
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
guelphdad will become famous soon enoughguelphdad will become famous soon enough
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.
guelphdad is offline   Reply With Quote
Users who have thanked guelphdad for this post:
sanomani (09-27-2012)
Old 09-27-2012, 07:37 PM   PM User | #3
sanomani
New Coder

 
Join Date: Jun 2012
Posts: 26
Thanks: 9
Thanked 0 Times in 0 Posts
sanomani is an unknown quantity at this point
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..
sanomani is offline   Reply With Quote
Old 09-27-2012, 07:40 PM   PM User | #4
sanomani
New Coder

 
Join Date: Jun 2012
Posts: 26
Thanks: 9
Thanked 0 Times in 0 Posts
sanomani is an unknown quantity at this point
Awesome!

Lots of thanks. You solved the problem.
sanomani is offline   Reply With Quote
Old 09-28-2012, 01:02 AM   PM User | #5
guelphdad
Super Moderator


 
guelphdad's Avatar
 
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
guelphdad will become famous soon enoughguelphdad will become famous soon enough
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
guelphdad 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 05:28 AM.


Advertisement
Log in to turn off these ads.