lovephp Posted October 5, 2012 Share Posted October 5, 2012 (edited) back again ok now i got problem getting $ to the $cid which i fetch from $_SESSION it only prints the string not the $ and i have email ids stored by cid and if i do not get a $ in front of the cid the emails does not show up. whats the solution guys? $cid = $_SESSION['cid']; $to = $fData['email']; $to_company = "$cid"; Edited October 5, 2012 by lovephp Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 5, 2012 Share Posted October 5, 2012 What the what. You're doing it wrong... Quote Link to comment Share on other sites More sharing options...
lovephp Posted October 5, 2012 Author Share Posted October 5, 2012 i do not know either Jess lol i thought if i add the $cid it should fetch the emails but its not doing it Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 5, 2012 Share Posted October 5, 2012 Quote Link to comment Share on other sites More sharing options...
xyph Posted October 5, 2012 Share Posted October 5, 2012 Variables are parsed within a double-quoted string. http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double As you can see in the manual, in order to get a literal $, you must escape it with a leading backslash. Quote Link to comment Share on other sites More sharing options...
lovephp Posted October 5, 2012 Author Share Posted October 5, 2012 ok i explain again Global $cid01; Global $cid02; now $cid01 and $cid02 got email id stored in variable and $cid = $_SESSION['cid']; fetches only cid01 without $ when i add like this $to_company = "$cid01"; email sends but when i try $to_company = "$cid"; no email gets send Quote Link to comment Share on other sites More sharing options...
xyph Posted October 5, 2012 Share Posted October 5, 2012 Why not use the example that works then. The language barrier here seems too large to overcome. I'm really lost. Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted October 5, 2012 Share Posted October 5, 2012 You're doing it wrong. SOmewhere, some how, you're doing it wrong, but we honestly can't figure out what because none of this makes any sense. What do you HAVE: Show us the current value of $_SESSION['cid']. By itself. Not in a paragraph, not in a line of code, inside a [ code ] box by itself. What do you NEED: Show us the line of code without a variable in it that works. If you want $to_company = 'abc123' but $cid = 'abc', show us that. Quote Link to comment Share on other sites More sharing options...
lovephp Posted October 5, 2012 Author Share Posted October 5, 2012 i really apologize for my way of writing. im not very good in explaining things. i actually want $to_company = 'abc123'; to be like want $to_company = '$abc123'; but currently its not happening the way i am doing $cid = $_SESSION['cid']; $to = $fData['email']; $to_company = "$cid"; the code above only prints $to_company = 'abc123'; i believe Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 5, 2012 Share Posted October 5, 2012 WHY.... Quote Link to comment Share on other sites More sharing options...
lovephp Posted October 5, 2012 Author Share Posted October 5, 2012 me too dunno but if i do it this way $to_company = "$cid01"; then mail sends Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 5, 2012 Share Posted October 5, 2012 Post the code that sends the mail. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 5, 2012 Share Posted October 5, 2012 and what if you do global $cid; just winging it here without seeing the full code. Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted October 5, 2012 Share Posted October 5, 2012 ANSWER THE QUESTION I gave you very specific instructions. Inside a box. NOT IN A PARAGRAPH. NOT IN A LINE OF CODE We're not magic. That crystal ball jess printed earlier isn't real, it's an emoticon. Quote Link to comment Share on other sites More sharing options...
lovephp Posted October 5, 2012 Author Share Posted October 5, 2012 ok this sends Global $cid01; Global $cid02; $cid = $_SESSION['cid']; $to = $fData['email']; $to_company = "$cid01"; this don't Global $cid01; Global $cid02; $cid = $_SESSION['cid']; $to = $fData['email']; $to_company = "$cid"; Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 5, 2012 Share Posted October 5, 2012 :facewall: Quote Link to comment Share on other sites More sharing options...
kicken Posted October 5, 2012 Share Posted October 5, 2012 It sounds to me you want variable variables, which is also a 'You're doing it wrong!' situation. If I'm understanding right you have for example: $cid01 = 'some content'; $cid02 = 'some other content'; And then then $_SESSION['cid'] contains a value like 'cid01'; which you want to use to find that variable, eg: $cid = $_SESSION['cid']; //(ex 'cid01') echo $cid; //(you want to echo 'some content'; The syntax for that would be: $cid = $_SESSION['cid']; //(ex 'cid01') echo $$cid; //double-dollar sign However as mentioned, this is the wrong way to do it. Rather than numbered cid varibles, use an array to store you're content, then just index into that array: $cidcontent = array( 'some content', 'some other content' ); $cid = $_SESSION['cid']; //stores the number 1 for example echo $cidcontent[$cid]; //outputs 'some other content'; Quote Link to comment Share on other sites More sharing options...
lovephp Posted October 5, 2012 Author Share Posted October 5, 2012 and what if you do global $cid; just winging it here without seeing the full code. global $cid would not work because cid only gets like string like cid01 from the form but Global $cid01 is in the config file which got email id stored against it Quote Link to comment Share on other sites More sharing options...
lovephp Posted October 5, 2012 Author Share Posted October 5, 2012 It sounds to me you want variable variables, which is also a 'You're doing it wrong!' situation. If I'm understanding right you have for example: $cid01 = 'some content'; $cid02 = 'some other content'; And then then $_SESSION['cid'] contains a value like 'cid01'; which you want to use to find that variable, eg: $cid = $_SESSION['cid']; //(ex 'cid01') echo $cid; //(you want to echo 'some content'; The syntax for that would be: $cid = $_SESSION['cid']; //(ex 'cid01') echo $$cid; //double-dollar sign However as mentioned, this is the wrong way to do it. Rather than numbered cid varibles, use an array to store you're content, then just index into that array: $cidcontent = array( 'some content', 'some other content' ); $cid = $_SESSION['cid']; //stores the number 1 for example echo $cidcontent[$cid]; //outputs 'some other content'; yes yes u got me right Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted October 5, 2012 Share Posted October 5, 2012 Ok I'm done with you, I asked way too many times for the value of $cid and you just can't figure out how to answer me. Perhaps PHP is not for you. You don't have a variable called $cid. That's pretty obvious. You have $cid01. Why not just use $cid01? You have code that works. How is "ok it works" not the end of the conversation? Quote Link to comment Share on other sites More sharing options...
lovephp Posted October 5, 2012 Author Share Posted October 5, 2012 (edited) Ok I'm done with you, I asked way too many times for the value of $cid and you just can't figure out how to answer me. Perhaps PHP is not for you. You don't have a variable called $cid. That's pretty obvious. You have $cid01. Why not just use $cid01? You have code that works. How is "ok it works" not the end of the conversation? bro very sorry the value of $cid is cid01 which is in the session and Global $cid01 got a email id stored against it so does Global $cid02 and from session $cid either could come cid01 or cid02 which is coming anyways but just that when i use it in $to_company = "$cid"; no email gets sends Edited October 5, 2012 by lovephp Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 5, 2012 Share Posted October 5, 2012 but you have global $cid01; //outputs cid01 is this not the same as //outputs cid01 $cid = $_SESSION['cid']; Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 5, 2012 Share Posted October 5, 2012 yes yes u got me right Did you actually read his post? He explained the correct way to do it. Now do it that way. Quote Link to comment Share on other sites More sharing options...
lovephp Posted October 5, 2012 Author Share Posted October 5, 2012 but you have global $cid01; //outputs cid01 is this not the same as //outputs cid01 $cid = $_SESSION['cid']; no no global $cid01; //outputs someemail@somesite.com and $cid = $_SESSION['cid']; // outputs cid01 or cid02 Quote Link to comment Share on other sites More sharing options...
lovephp Posted October 5, 2012 Author Share Posted October 5, 2012 Did you actually read his post? He explained the correct way to do it. Now do it that way. yes Jess im getting it and i did try it that way still its not happening wonder why 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.