fieldy920 Posted January 21, 2009 Share Posted January 21, 2009 I am by no means an expert at this, but the following does not work: $body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } It is part of a larger script, however the script stops working directly at the end of "$a =>". It instead decides to print the rest of the script ($b and onwards) in the browser window. Is there anything else I need to be aware of or do you need me to post the entire script? Link to comment https://forums.phpfreaks.com/topic/141813-quick-question/ Share on other sites More sharing options...
Philip Posted January 21, 2009 Share Posted January 21, 2009 That is the correct syntax... $body = "We have received the following information:\n\n"; foreach($fields as $a => $b) { $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } The only thing I can think of, would be to put single quotes around $a in the $_REQUEST... but the script shouldnt print itself (you are saying it's printing the code, correct?) Link to comment https://forums.phpfreaks.com/topic/141813-quick-question/#findComment-742464 Share on other sites More sharing options...
fieldy920 Posted January 21, 2009 Author Share Posted January 21, 2009 This is making me want to throw a brick through my screen... Now my browser (after hitting submit on a form) continually loops opening the php file in a new tab. Link to comment https://forums.phpfreaks.com/topic/141813-quick-question/#findComment-742476 Share on other sites More sharing options...
Philip Posted January 21, 2009 Share Posted January 21, 2009 Okay, if you take out that loop - does it do anything odd? Like this: <?php $body = "We have received the following information:\n\n"; /*foreach($fields as $a => $b) { $body .= sprintf("%20s: %s\n",$b,$_REQUEST['$a']); }*/ ?> And that works okay? if so, can you print_f($fields)? Link to comment https://forums.phpfreaks.com/topic/141813-quick-question/#findComment-742480 Share on other sites More sharing options...
fieldy920 Posted January 21, 2009 Author Share Posted January 21, 2009 I can put <?php echo "Hello World!"; ?> and execute it and it loops opening the damn thing... Link to comment https://forums.phpfreaks.com/topic/141813-quick-question/#findComment-742489 Share on other sites More sharing options...
Philip Posted January 21, 2009 Share Posted January 21, 2009 Try this: <?php $body = "We have received the following information:\n\n"; echo '<pre>'; print_r($fields); echo '</pre>'; /*foreach($fields as $a => $b) { $body .= sprintf("%20s: %s\n",$b,$_REQUEST['$a']); }*/ ?> Link to comment https://forums.phpfreaks.com/topic/141813-quick-question/#findComment-742522 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.