Note that there are some explanatory texts on larger screens.

plurals
  1. POarray_values works in localhost, but returns nothing on server?
    text
    copied!<p>Update: I found the cause. It was because the file only had carriage returns. After replacing them with CR+LF (<code>\r\n</code>), it works normally on the server.</p> <p>Original post: </p> <p>I just uploaded my site to my webhost and I noticed a strange issue regarding POST data. On localhost, everything works as it should, but on the server for some reason the POST data seems to vanish in the middle of processing?</p> <p>The site submits data from a form to guestbookFormProcessor.php:</p> <pre><code>&lt;!doctype html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;title&gt;Add Guestbook Comment&lt;/title&gt; &lt;meta charset="UTF-8" /&gt; &lt;/head&gt; &lt;body&gt; &lt;?php var_dump($_POST); // This returns data OK on the server // Process POST data $unsafeFormData = array_values($_POST); var_dump($unsafeFormData); // This returns nothing on the server! // anything after this point will not appear on the page, not even echos ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>But that outputs nothing at all on the server! </p> <p>If I add an <code>echo 'Test';</code>, it appears on the page, but if I add it <em>after</em> the <code>$unsafeFormData = array_values($_POST);</code> then it does <strong>not</strong> appear?!</p> <p>In fact, anything I add after that row, does not appear on the page. I also checked for any strange characters in the row, but it looks normal even to a hex editor. What could be wrong? It seems to be related to the array_values() function since this happens:</p> <p><code>var_dump($_POST);</code><br> array(5) { ["name"]=> string(4) "Juha" ["antispam"]=> string(1) "4" ["antispamIndex"]=> string(1) "1" ["message"]=> string(4) "Test" ["submit"]=> string(4) "Send" } </p> <p><code>var_dump($unsafeFormData);</code><br> (no output at all!)</p> <p>Why would the POST data disappear after array_values()?</p> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload