Jump to content

Problem with concenating a string for some reason.


jayhawker

Recommended Posts

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";

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.