By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 941 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

Updating a database via a textarea

P: 7
I have a textarea that is used to view a specific database cell, which works fine. The problem is when I edited the text in that textarea and then use php + mysql to update that specific database cell it does not work. When I just change the name to a random string "abc" the database is updated but it takes 2 clicks to work or 2 refreshers. So I found the problem line in the code but dont know what to do:

PHP problem:
$post_textWelcome = $_POST[text_welcome]; // PROBLEM HERE

text_welcome being the name/id of the textarea.

MySQL query:
"UPDATE $table1 SET $primaryKey1 = '$post_textWelcome' WHERE welcome = '1'";

just for further information but this query works. Like I said if i change the PHP problem to: $post_textWelcome ="abc";
updates the text fine, well if i can aid you any further let me know but im hoping that you can solve my problem =)

Thanks in advance, Regards X
Dec 30 '07 #1
Share this Question
Share on Google+
5 Replies

Expert 5K+
P: 6,050
Are you sure you're using POST to send the data?

Also, it's good practice to wrap array keys in single quotes..


$something = $_POST['wrapped_with_single_quotes'];
Dec 30 '07 #2

P: 7
ya i have wrapped it in quotes ' ' and not it dosent work either way.
Something wrong with that line of code because I cannot understand why it works with a string variable and will not with a post.

What did you mean by am i using $_POST to send?

im using post to gather the information that is contained within the textarea to make it equal to the variable?

im a newbie at php and trying to learn everything off my own back and its very hard at times =( been on this problem for 3 days and cant find a solution. Maybe someone can give me a working example of a textarea that is used to to call text into the textarea and that same textarea is used to update that cell?

Thanks Again, Regards X
Dec 30 '07 #3

Expert 5K+
P: 6,050
First) The data submitted from the textarea has to come from a form and that form has to have a method - POST or GET. The code that you use to retrieve the data has to be respective to the method you use.

i.e. if you use a method=POST then you have to use $_POST to retrieve it.
Dec 30 '07 #4

P: 7

Something is buggy or my code is just really bad.... lol

Thanks for the help man. Something weird happened, I had post previously to encrypt the sent message and nothing was happening. I change them both to get and the message was working and then i change them back to post and it works fine now. So why was it not working orginally? =(

So the only problem I face now is that somehow its storing and retreiving 2 different variables in the textarea. Eg. textarea loads with 123a and then I change that to 123b click the submit button and 123a appears. click the submit button again and 123b appears. Any Ideas?

Happy New Year people, thanks again, X ;)
Dec 31 '07 #5

P: 7
I just solved the problem, thanks for the help!

Dec 31 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.