Jax2 Posted April 7, 2010 Share Posted April 7, 2010 Perhaps I misunderstood, but I thought that if you declared a variable, you could add onto it later in the script... such as something like this: $body="This is the first line of the text.\r\n"; $body .="This will be inserted below the first line. Therefore it's the second.\r\n"; $body .="This will be considered the 3rd line."; Which I thought would produce: $body="This is the first line of the text.\r\n This will be inserted below the first line. Therefore it's the second.\r\n This will be considered the 3rd line." Am I mistaken here? I have a script that has to perform a couple of while loops in order to insert array data into the body of an email I'm sending, yet when I did it like this, $body was blank. Any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/197906-question-regarding-adding-onto-a-variable-that-contains-text/ Share on other sites More sharing options...
schilly Posted April 7, 2010 Share Posted April 7, 2010 That's correct. Post the code in question. Quote Link to comment https://forums.phpfreaks.com/topic/197906-question-regarding-adding-onto-a-variable-that-contains-text/#findComment-1038512 Share on other sites More sharing options...
PFMaBiSmAd Posted April 7, 2010 Share Posted April 7, 2010 There's nothing wrong with what you are doing (test it in a file by itself.) If you are getting an empty variable later in your code, either your code is clearing the variable or the variable is not available due to it being in a different scope. You would need to pin down where in your code the variable has the expected content and where it does not. If you want us to help determine where in your code that is occurring, you will need to post your code. Quote Link to comment https://forums.phpfreaks.com/topic/197906-question-regarding-adding-onto-a-variable-that-contains-text/#findComment-1038513 Share on other sites More sharing options...
Jax2 Posted April 7, 2010 Author Share Posted April 7, 2010 I did what was suggested and tried it out in a simple test.php script and yes, it worked perfectly. I had been rechecking my code for a good hour before I decided to ask the question because nothing was coming up correctly. Dun dun duuuuun..... I had spelled recipeID as recpieID and it couldn't find the recipe in question so it returned nothing. (slaps self on forehead). You'd think I'd have started by echoing back the variables at the top of the page to make sure they were being passed correctly, wouldn't you? Quote Link to comment https://forums.phpfreaks.com/topic/197906-question-regarding-adding-onto-a-variable-that-contains-text/#findComment-1038524 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.