A JM Posted December 15, 2009 Share Posted December 15, 2009 I'm trying to concantonate a string with the following and I don't understand why its wrong, can someone help? $VEND = "VEND" . "t\" . $row['lastname'] . ", " . $row['firstname'] . "t\t\t\t\t\" . $row['company'] . "t\" . $row['email'] . "t\" . $row['cell'] . ", " . $row['fax'] . "t\t\t\t\t\t\t\t\t\" . "Y" . "t\t\t\t\t\t\t\t\t\t\t\t\t" . "\r\n"; A JM, Link to comment https://forums.phpfreaks.com/topic/185205-string-concantonation-problem/ Share on other sites More sharing options...
otuatail Posted December 15, 2009 Share Posted December 15, 2009 You dont need all thouse strings $VEND = "VEND" . "t\ $row['lastname'] , $row['firstname'] t\t\t\t\t\ $row['company'] t\ $row['email'] t\ $row['cell'] , $row['fax'] t\t\t\t\t\t\t\t\t\ Y t\t\t\t\t\t\t\t\t\t\t\t\t\r\n"; Link to comment https://forums.phpfreaks.com/topic/185205-string-concantonation-problem/#findComment-977696 Share on other sites More sharing options...
cags Posted December 15, 2009 Share Posted December 15, 2009 If you use a syntax highlighter, the reason becomes fairly obvious (IMO)... $VEND = "VEND" . "t\" . $row['lastname'] . ", " .$row['firstname'] . "t\t\t\t\t\" . $row['company'] . "t\" .$row['email'] . "t\" . $row['cell'] . ", " . $row['fax'] ."t\t\t\t\t\t\t\t\t\" . "Y" . "t\t\t\t\t\t\t\t\t\t\t\t\t" . "\r\n"; In case you can't see it, the backslash right before the closing string delimiters (") are escaping the character, thus PHP believes that it is not the delimiter and looks for the rest of the string. You can fix the problem by escaping the last backslash, that is to say placing another backslash before it so that PHP knows it's a literal backslash. Having said this I doubt that's actually what you want, why have you got so many t\'s in your code anyway? Surely that can't mean a great deal. Link to comment https://forums.phpfreaks.com/topic/185205-string-concantonation-problem/#findComment-977698 Share on other sites More sharing options...
A JM Posted December 15, 2009 Author Share Posted December 15, 2009 Thanks, I'm trying to create a TAB formatted string... cags, I got a few extra"\" and t's when I double back slashed the t's like the following.. $VEND = "VEND" . "t\\" . $row['lastname'] . ", " . $row['firstname'] . "t\t\t\t\t\\" . $row['company'] . "t\\" . $row['email'] . "t\\" . $row['cell'] . ", " . $row['fax'] . "t\t\t\t\t\t\t\t\t\\" . "Y" . "t\t\t\t\t\t\t\t\t\t\t\t\t\\" . "\r\n"; I got the following error when trying your example otuatail: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /myweb.com/QB.php on line 174 $VEND = "VEND" . "t\ $row['lastname'] , $row['firstname'] t\t\t\t\t\ $row['company'] t\ $row['email'] t\ $row['cell'] , $row['fax'] t\t\t\t\t\t\t\t\t\ Y t\t\t\t\t\t\t\t\t\t\t\t\t\r\n"; Link to comment https://forums.phpfreaks.com/topic/185205-string-concantonation-problem/#findComment-978127 Share on other sites More sharing options...
cags Posted December 15, 2009 Share Posted December 15, 2009 A tab is \t not t\. I'll say it again, use something that syntax highlights you can see the point where it breaks! Link to comment https://forums.phpfreaks.com/topic/185205-string-concantonation-problem/#findComment-978128 Share on other sites More sharing options...
A JM Posted December 15, 2009 Author Share Posted December 15, 2009 I'm using dreamweaver... arrgh... I missed the t\ v.s. \t. Thanks, Link to comment https://forums.phpfreaks.com/topic/185205-string-concantonation-problem/#findComment-978132 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.