psychowolvesbane Posted January 4, 2008 Share Posted January 4, 2008 I have a line and I want to get it so that the value of CampusID is "Campus & value of NumberOfRecords+1". But I'm not sure on the correct concatenate method. $CampusID = "Campus" '.' $NumberOfRecords+1'; ($NumberOfRecords is 2 btw) Link to comment https://forums.phpfreaks.com/topic/84508-solved-concatenate-help/ Share on other sites More sharing options...
duclet Posted January 4, 2008 Share Posted January 4, 2008 $CampusID = "Campus".($NumberOfRecords+1); Link to comment https://forums.phpfreaks.com/topic/84508-solved-concatenate-help/#findComment-430566 Share on other sites More sharing options...
Wuhtzu Posted January 4, 2008 Share Posted January 4, 2008 Your syntax is wrong, this is correct: $CampusID = "Campus " . $NumberOfRecords+1; or $CampusID = "Campus" . " " . $NumberOfRecords+1; . (dot) is used to join strings and variables together so the correct syntax is like: $new string = "string" . "anotherstring" . $variable . "yet another string" . $andavariable; Link to comment https://forums.phpfreaks.com/topic/84508-solved-concatenate-help/#findComment-430567 Share on other sites More sharing options...
psychowolvesbane Posted January 4, 2008 Author Share Posted January 4, 2008 No it hasn't worked, I have $NumberOfRecords as 1 and I used both $CampusID = "Campus " . $NumberOfRecords+1; or $CampusID = "Campus" . " " . $NumberOfRecords+1; and the value for $CampusID I am getting is just "1". Link to comment https://forums.phpfreaks.com/topic/84508-solved-concatenate-help/#findComment-430578 Share on other sites More sharing options...
duclet Posted January 4, 2008 Share Posted January 4, 2008 What, you didn't try mine? Link to comment https://forums.phpfreaks.com/topic/84508-solved-concatenate-help/#findComment-430579 Share on other sites More sharing options...
psychowolvesbane Posted January 4, 2008 Author Share Posted January 4, 2008 Ah sorry but duclet's method has worked and it is problem solved! Thanks! Link to comment https://forums.phpfreaks.com/topic/84508-solved-concatenate-help/#findComment-430580 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.