croakingtoad Posted June 29, 2007 Share Posted June 29, 2007 I am getting this error- Parse error: syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/health1/public_html/bedside-manner.php on line 43 with this bit of code- 35 for ($i = 0; $i < count($array); $i++) { 36 37 //removes characters in $chars from $array items 38 $chars = array(" ", "&", "(", ")", "/"); 39 $trim = str_replace ($chars, "", $array[$i]); 40 41 $message .= " 42 $array[$i] 43 1st $_POST['$trim-1'] 44 2nd $_POST['$trim-2'] 45 3rd $_POST['$trim-3'] 46 47 "; 48 49 } This is a bit of code I have to try to handle the results of a form submit without having to manually code every var into the phpmail message. These values are handled the same way in the creation of the form. Just as an FYI, here's what my form looks like but it is not where I'm having the problem-- for ($i = 0; $i < count($array); $i++) { //removes characters in $chars from $array items $chars = array(" ", "&", "(", ")", "/"); $trim = str_replace ($chars, "", $array[$i]); if ($i & 2 != 0) { echo "<fieldset>"; } else { echo " <fieldset style=\"float: left;\">"; } echo " <legend>$array[$i]</legend> <input type=\"text\" name=\"$trim-1\" size=\"30\" /> <label>1st</label> <br /> <input type=\"text\" name=\"$trim-2\" size=\"30\" /> <label>2nd</label> <br /> <input type=\"text\" name=\"$trim-3\" size=\"30\" /> <label>3rd</label> </fieldset> "; } This form is submitting to itself... Link to comment https://forums.phpfreaks.com/topic/57715-t_string-error/ Share on other sites More sharing options...
bbaker Posted June 29, 2007 Share Posted June 29, 2007 there shouldn't be $'s in there 43 1st $_POST['$trim-1'] 44 2nd $_POST['$trim-2'] 45 3rd $_POST['$trim-3'] Link to comment https://forums.phpfreaks.com/topic/57715-t_string-error/#findComment-285821 Share on other sites More sharing options...
croakingtoad Posted June 29, 2007 Author Share Posted June 29, 2007 Hmm...but I was hoping for a shortcut to keep from having to manually pull all the vars out of there. $trim is the var. Is there another way of doing that? Link to comment https://forums.phpfreaks.com/topic/57715-t_string-error/#findComment-285833 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.