Getting data from a form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shuka
Forum Newbie
Posts: 3
Joined: Mon Jul 09, 2007 12:17 pm

Getting data from a form

Post by shuka »

pickle | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi Guys,

Just started to learn PHP and am slowly getting to hang of it, have currently got a form that consists of tickbox, with each one with a different ID that is assigned by the database when it creates the form, as each form is different depending on the user.

How managed to get it to recoginse what the form elements ID are so it can request the correct form element,

so in a while statement am going throught the ID to get the data using the following

[syntax="php"]while($rowCheck = mysql_fetch_array($resCheck))
{
   $strValue = $_POST['$rowCheck[TaskID];'];
   echo $strValue; ?> </br> <?
}
$rowCheck[TaskID] is the ID of the form element am trying to get from the form

But this is not beginning anything back to the screen all am getting is a blank screen, hope someone can help me.

Cheers in advanced

Shuka


pickle | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
TheMoose
Forum Contributor
Posts: 351
Joined: Tue May 23, 2006 10:42 am

Post by TheMoose »

Close, but your quotes are in the wrong positions.

Code: Select all

$strValue = $_POST[$rowCheck['TaskID']];
shuka
Forum Newbie
Posts: 3
Joined: Mon Jul 09, 2007 12:17 pm

Post by shuka »

That works!!! Cheers your a life saver that has driving me nuts for the last hour :D

Shuka
shuka
Forum Newbie
Posts: 3
Joined: Mon Jul 09, 2007 12:17 pm

Post by shuka »

got another problem when inserting into a mySQL database back end, i have a insert statement

Code: Select all

<? echo $insertTS = "INSERT INTO `Tasksheet` (`userid`, `taskdate`, `taskID`, `taskValue`) VALUES ('$rowUser[userID]', CURDATE( ) , `$rowCheck[TaskID]`, '$strValue')"; ?></br><?
am getting the following output

Code: Select all

INSERT INTO `Tasksheet` (`userid`, `taskdate`, `taskID`, `taskValue`) VALUES ('3', CURDATE( ) , `2`, '0')
Unknown column '2' in 'field list'INSERT INTO `Tasksheet` (`userid`, `taskdate`, `taskID`, `taskValue`) VALUES ('3', CURDATE( ) , `27`, '1')
Unknown column '27' in 'field list'INSERT INTO `Tasksheet` (`userid`, `taskdate`, `taskID`, `taskValue`) VALUES ('3', CURDATE( ) , `6`, '1')
Unknown column '6' in 'field list'INSERT INTO `Tasksheet` (`userid`, `taskdate`, `taskID`, `taskValue`) VALUES ('3', CURDATE( ) , `25`, '1')
Unknown column '25' in 'field list'INSERT INTO `Tasksheet` (`userid`, `taskdate`, `taskID`, `taskValue`) VALUES ('3', CURDATE( ) , `4`, '1')
Unknown column '4' in 'field list'INSERT INTO `Tasksheet` (`userid`, `taskdate`, `taskID`, `taskValue`) VALUES ('3', CURDATE( ) , `5`, '0')
Unknown column '5' in 'field list'
can't figure out why it is stating/thing that the number is a number when it is already state the field name is taskID

Cheers

Neil
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post by Begby »

Try changing the backticks (`) to single quotes (') around the numberes that are triggering the error.
Post Reply