Note that there are some explanatory texts on larger screens.

plurals
  1. POWeird PHP session
    text
    copied!<p>I've got a perfectly functioning site which uses sessions. The only exception, is one particular page. The page performs some DB SELECTS, verification stuff, etc. etc. Then, later on, in the HTML part, ive got a tag. Between that, ive got</p> <pre><code>&lt;?php $classes = explode(",", $_SESSION['classes']); foreach ($classes as $class) { echo "&lt;option&gt;".$class."&lt;/option&gt;"; } ?&gt; </code></pre> <p>Now $_SESSION['classes'] is a comma separated string. Example: "10 A,11 D,12 C" here's the weird part, when i load this page, everything works perfectly, and i get a drop-down select with options 10 A, 11 D and 12 C... but, when i refresh the page, I get a dropdown box with only one option: <code>Array</code></p> <p>Yes, it just says Array.... no other options.</p> <p>And no, i haven't set the value to anything else after that PHP block. in fact, i dont have another PHP block after this one</p> <p>To debug it, I added a php block with the code: <code>echo $_SESSION['classes'];</code> after the <code>&lt;/select&gt;</code> tag, and the first page load, it said <code>10 A,11 D,12 C</code>. After refresh, it said <code>Array</code></p> <p>Then i tried <code>var_dump($_SESSION);</code> and it said <code>["classes"]=&gt; &amp;string(9) "11 A,10 C"</code> <strong>Heres the weirdest part:</strong> After refresh, it said <code>["classes"]=&gt; &amp;array(2) { [0]=&gt; string(4) "11 A" [1]=&gt; string(4) "10 C" }</code> and on another refresh, it said <code>["classes"]=&gt; &amp;array(1) { [0]=&gt; string(5) "Array" }</code></p> <p><strong>This only happens on my web host though, not on my local server. And, only on this page</strong></p> <p>I have no idea what's causing this, or how to fix it</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