title: php Illegal string offset
body: <p>I have some problems with outputting my array. Basically, some documents and additional info are being uploaded to database, and i would like to display download link and that uploaded details (onclick) about them afterwards.
  This is my code:</p>
  
  <pre><code>$sqlresult = mysql_query("SELECT DISTINCT u.username, p.p_url FROM users AS u INNER JOIN papers AS p ON p.user_id = u.user_id WHERE username = '{$_SESSION['user']}'");
  $check_row = mysql_num_rows($sqlresult);
  $counter = 1;
  $output = "";
  $outarray = array();
  if ($check_row &gt; 0) {
    while ($output = mysql_fetch_array($sqlresult)) {
      $outarray[1] = $output[1];
      if (is_array($outarray)) {
        foreach ($outarray as $val) {
          $query = mysql_query("SELECT p_name, p_authors, p_corresponding, p_email, p_cauthor, p_abstract, p_jname, p_date FROM papers INNER JOIN users ON papers.user_id = users.user_id WHERE p_url = '$val' AND username='{$_SESSION['user']}'");
          $last = mysql_fetch_assoc($query);
          foreach ($last as $key =&gt; $value){
            // echo "$key"."=="."$value";
            $search = substr($val, 0, strpos($val, '.'));
            $trim = str_replace($val, '', $search);
            $counter++;
          }
        }
        echo &lt;&lt;&lt;HERE
        &lt;a href="http://localhost:8080/laboratory/users/{$_SESSION['user']}/{$val}" target="_blank"&gt;{$trim}&lt;/a&gt;&amp;nbsp;&amp;nbsp;
        &lt;a href="#collapse{$counter}" style="text-decoration: none; font-size: 14px; " onclick="$('p').show();return false;" class="nav-toggle"&gt;+ See details&lt;/a&gt;
  
        &lt;div id="collapse{$counter}" style="display:none"&gt;
        &lt;p&gt;Name:{$value['p_name']}, Author:{$value['p_authors']}, Corresponding author:{$value['p_corresponding']}, etc ...&lt;/p&gt;
        &lt;/div&gt;  
        &lt;br /&gt;
        HERE;
      }
    }
  } else {                           
    echo "You don't have any papers uploaded !";
  }
  }
  }
  </code></pre>
  
  <p>And i got warning: "Warning: Illegal string offset", but how is that possible when second foreach loop gives proper output (commented echo part) ? Any suggestions ? Thank you.</p>