jayhawker Posted March 29, 2011 Share Posted March 29, 2011 I normally don't have a problem with concenation, but for some reason I can't get it work in this case. I have two form variables: firstname_ord and lastname_ord. I have tried concenating them several ways, and get nothing afterwards. attempt 1: $lastname = "firstname_ord" . " " . "lastname_ord"; attempt 2: $firstname = "firstname_ord"; $lastname = "lastname_ord"; $fullname = $firstname . " " . $lastname; attempt 3: $fullname = "firstname_ord"; $fullname = $fullname. " " . "lastname_ord"; attempt 4: $fullname = "firstname_ord"; $fullname .="lastname_ord"; attempt 5: $fullname = (string)"firstname_ord"; $fullname .= " "; $fullname .=(string)"lastname_ord"; Quote Link to comment Share on other sites More sharing options...
Adam Posted March 29, 2011 Share Posted March 29, 2011 In 'attempt 1', I don't see any variables being used except for $lastname? Where do you have the form inputs? Quote Link to comment Share on other sites More sharing options...
mikecampbell Posted March 29, 2011 Share Posted March 29, 2011 $firstname = "firstname_ord"; $lastname = "lastname_ord"; $fullname = $firstname . " " . $lastname; echo $fullname; Are you saying that this does not echo "firstname_ord lastname_ord"? If so, then what result are you expecting? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 29, 2011 Share Posted March 29, 2011 What are you getting with each attempt? Ken Quote Link to comment Share on other sites More sharing options...
jayhawker Posted March 29, 2011 Author Share Posted March 29, 2011 Thanks for the replies. I am not normally using PHP (.net instead) and so I may be making some wrong assumptions here. This is some rather old code that I didn't write, and I am trying to fix some things that never worked. The existing code updates a record like this: $updRecord_ord->addColumn("firstname_ord", "STRING_TYPE", "POST", "firstname_ord"); I can put any single form variable (i.e. lastname_ord, address_ord) in where the second "firstname_ord" is, and I do not have a problem. But if I try to place a variable that has been concenated instad, I get nothing as a result. No error, just nothing. If I have a name in the firstname field of the textbox, the record gets updated with the first name. Here is a sample of the code: $firstname = "firstname_ord". " " . "lastname_ord"; $updRecord_ord->addColumn("firstname_ord", "STRING_TYPE", "POST", $firstname); firstname_ord and lastname_ord are names of textboxes as well as to have matcing names for columns in a MySQL Table. They are in a table as such: <td> input type="text" name="firstname_ord" id="firstname_ord" value="<?php echo ASescapeAttribute($row_rs_ord['firstname_ord']); ?>" /> </td> </tr> <tr> <td><input type="text" name="lastname_ord" id="lastname_ord" value="<?php echo ASescapeAttribute($row_rs_ord['lastname_ord']); ?>" /> </td> </tr> Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 29, 2011 Share Posted March 29, 2011 Are you sure this line <?php $firstname = "firstname_ord". " " . "lastname_ord"; ?> didn't have "$" before "firstname_ord" & "lastname_ord"? If there was a "$" preceding those strings, then the old code would have been written at a time when register_globals was enabled. That line would now product the value of "firstname_ord lastname_ord" in $firstname. If you want the value of the text boxes in the form, you would need something like: <?php $firstname = "{$_POST['firstname_ord']} {$_POST['lastname_ord']}"; ?> Ken Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.