Jump to content

Weird errors


jamesxg1

Recommended Posts

Hiya,

 

I have this code.

 

foreach($_POST as $key => $val):
echo "<code>isset($_POST['</code>" . $key . "<code>']) && !empty($_POST['</code>" . $key . "<code>']) &&</code>";
endforeach;

 

And I get these errors.

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

 

Many thanks

 

James.

Link to comment
https://forums.phpfreaks.com/topic/193604-weird-errors/
Share on other sites

Hiya mate,

 

Cheers for the reply.

 

I got it working, I forgot to escape the $_POST varible.

 

Here's the working code.

 

foreach($_POST as $key => $val):
echo "isset(\$_POST['" . $key . "']) && !empty(\$_POST['" . $key . "']) && ";
endforeach;

 

Many thanks

 

James.

Link to comment
https://forums.phpfreaks.com/topic/193604-weird-errors/#findComment-1019152
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.